[PATCH] swsusp: do not leak memory if there's an error during suspend

From: Rafael J. Wysocki
Date: Sat Mar 19 2005 - 09:35:51 EST


Hi,

The following patch prevents swsusp from leaking memory if there's an error
during suspend (eg when device_power_down() returns non-zero).

Greets,
Rafael


Signed-off-by: Rafael J. Wysocki <rjw@xxxxxxx>

--- linux-2.6.12-rc1-a/kernel/power/swsusp.c 2005-03-19 11:51:02.000000000 +0100
+++ linux-2.6.12-rc1-b/kernel/power/swsusp.c 2005-03-19 15:16:56.000000000 +0100
@@ -894,10 +894,12 @@ int swsusp_suspend(void)
*/
if ((error = device_power_down(PMSG_FREEZE))) {
local_irq_enable();
+ swsusp_free();
return error;
}
save_processor_state();
- error = swsusp_arch_suspend();
+ if ((error = swsusp_arch_suspend()))
+ swsusp_free();
/* Restore control flow magically appears here */
restore_processor_state();
BUG_ON (nr_copy_pages_check != nr_copy_pages);

--
- Would you tell me, please, which way I ought to go from here?
- That depends a good deal on where you want to get to.
-- Lewis Carroll "Alice's Adventures in Wonderland"
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/