提交 bb58dd5d 编写于 作者: R Rafael J. Wysocki

PM / Hibernate: Do not leak memory in error/test code paths

The hibernation core code forgets to release memory preallocated
for hibernation if there's an error in its early stages or if test
modes causing hibernation_snapshot() to return early are used.  This
causes the system to be hardly usable, because the amount of
preallocated memory is usually huge.  Fix this problem.
Reported-by: NSrivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com>
Signed-off-by: NRafael J. Wysocki <rjw@sisk.pl>
Acked-by: NSrivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com>
上级 f10cdea6
...@@ -347,7 +347,7 @@ int hibernation_snapshot(int platform_mode) ...@@ -347,7 +347,7 @@ int hibernation_snapshot(int platform_mode)
error = freeze_kernel_threads(); error = freeze_kernel_threads();
if (error) if (error)
goto Close; goto Cleanup;
if (hibernation_test(TEST_FREEZER) || if (hibernation_test(TEST_FREEZER) ||
hibernation_testmode(HIBERNATION_TESTPROC)) { hibernation_testmode(HIBERNATION_TESTPROC)) {
...@@ -357,12 +357,14 @@ int hibernation_snapshot(int platform_mode) ...@@ -357,12 +357,14 @@ int hibernation_snapshot(int platform_mode)
* successful freezer test. * successful freezer test.
*/ */
freezer_test_done = true; freezer_test_done = true;
goto Close; goto Cleanup;
} }
error = dpm_prepare(PMSG_FREEZE); error = dpm_prepare(PMSG_FREEZE);
if (error) if (error) {
goto Complete_devices; dpm_complete(msg);
goto Cleanup;
}
suspend_console(); suspend_console();
pm_restrict_gfp_mask(); pm_restrict_gfp_mask();
...@@ -391,8 +393,6 @@ int hibernation_snapshot(int platform_mode) ...@@ -391,8 +393,6 @@ int hibernation_snapshot(int platform_mode)
pm_restore_gfp_mask(); pm_restore_gfp_mask();
resume_console(); resume_console();
Complete_devices:
dpm_complete(msg); dpm_complete(msg);
Close: Close:
...@@ -402,6 +402,10 @@ int hibernation_snapshot(int platform_mode) ...@@ -402,6 +402,10 @@ int hibernation_snapshot(int platform_mode)
Recover_platform: Recover_platform:
platform_recover(platform_mode); platform_recover(platform_mode);
goto Resume_devices; goto Resume_devices;
Cleanup:
swsusp_free();
goto Close;
} }
/** /**
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册