[PATCH 4/4] hibernate: fix disk and module leak on successfull resume

From: Roman Pen
Date: Mon Feb 01 2016 - 09:52:52 EST


Do not forget to put the disk back.

Signed-off-by: Roman Pen <roman.penyaev@xxxxxxxxxxxxxxxx>
Cc: Gi-Oh Kim <gi-oh.kim@xxxxxxxxxxxxxxxx>
Cc: "Rafael J. Wysocki" <rjw@xxxxxxxxxxxxx>
Cc: Len Brown <len.brown@xxxxxxxxx>
Cc: Pavel Machek <pavel@xxxxxx>
Cc: linux-pm@xxxxxxxxxxxxxxx
Cc: linux-kernel@xxxxxxxxxxxxxxx
---
kernel/power/hibernate.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/kernel/power/hibernate.c b/kernel/power/hibernate.c
index b7342a2..1f53dc2 100644
--- a/kernel/power/hibernate.c
+++ b/kernel/power/hibernate.c
@@ -785,8 +785,11 @@ static int software_resume(void)
*/
if (isdigit(resume_file[0]) && resume_wait) {
int partno;
- while (!get_gendisk(swsusp_resume_device, &partno))
+ struct gendisk *disk;
+
+ while (!(disk = get_gendisk(swsusp_resume_device, &partno)))
msleep(10);
+ put_gendisk(disk);
}

if (!swsusp_resume_device) {
--
2.6.2