PM / Hibernate: Fix blkdev refleaks
While cruising through the swsusp code I found few blkdev reference leaks of resume_bdev. swsusp_read: remove blkdev_put altogether. Some fail paths do not do that. swsusp_check: make sure we always put a reference on fail paths software_resume: all fail paths between swsusp_check and swsusp_read omit swsusp_close. Add it in those cases. And since swsusp_read doesn't drop the reference anymore, do it here unconditionally. [rjw: Fixed a small coding style issue.] Signed-off-by: Jiri Slaby <jirislaby@gmail.com> Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
This commit is contained in:
committed by
Rafael J. Wysocki
parent
9905d1b411
commit
76b57e613f
@@ -693,21 +693,22 @@ static int software_resume(void)
|
||||
/* The snapshot device should not be opened while we're running */
|
||||
if (!atomic_add_unless(&snapshot_device_available, -1, 0)) {
|
||||
error = -EBUSY;
|
||||
swsusp_close(FMODE_READ);
|
||||
goto Unlock;
|
||||
}
|
||||
|
||||
pm_prepare_console();
|
||||
error = pm_notifier_call_chain(PM_RESTORE_PREPARE);
|
||||
if (error)
|
||||
goto Finish;
|
||||
goto close_finish;
|
||||
|
||||
error = usermodehelper_disable();
|
||||
if (error)
|
||||
goto Finish;
|
||||
goto close_finish;
|
||||
|
||||
error = create_basic_memory_bitmaps();
|
||||
if (error)
|
||||
goto Finish;
|
||||
goto close_finish;
|
||||
|
||||
pr_debug("PM: Preparing processes for restore.\n");
|
||||
error = prepare_processes();
|
||||
@@ -719,6 +720,7 @@ static int software_resume(void)
|
||||
pr_debug("PM: Reading hibernation image.\n");
|
||||
|
||||
error = swsusp_read(&flags);
|
||||
swsusp_close(FMODE_READ);
|
||||
if (!error)
|
||||
hibernation_restore(flags & SF_PLATFORM_MODE);
|
||||
|
||||
@@ -737,6 +739,9 @@ static int software_resume(void)
|
||||
mutex_unlock(&pm_mutex);
|
||||
pr_debug("PM: Resume from disk failed.\n");
|
||||
return error;
|
||||
close_finish:
|
||||
swsusp_close(FMODE_READ);
|
||||
goto Finish;
|
||||
}
|
||||
|
||||
late_initcall(software_resume);
|
||||
|
Reference in New Issue
Block a user