From: Rafael J. Wysocki <rjw@xxxxxxx> We only can try to allocate memory for saving the NVS region if it is known that the target system sleep state is valid. Otherwise we will leak memory if suspend_nvs_alloc() is successful and the target state is invalid, because suspend_nvs_free() will not be called in that case. Signed-off-by: Rafael J. Wysocki <rjw@xxxxxxx> --- drivers/acpi/sleep.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) Index: linux-2.6/drivers/acpi/sleep.c =================================================================== --- linux-2.6.orig/drivers/acpi/sleep.c +++ linux-2.6/drivers/acpi/sleep.c @@ -195,20 +195,15 @@ static u32 acpi_suspend_states[] = { static int acpi_suspend_begin(suspend_state_t pm_state) { u32 acpi_state = acpi_suspend_states[pm_state]; - int error = 0; - - error = suspend_nvs_alloc(); - - if (error) - return error; + int error = -ENOSYS; if (sleep_states[acpi_state]) { acpi_target_sleep_state = acpi_state; acpi_sleep_tts_switch(acpi_target_sleep_state); + error = suspend_nvs_alloc(); } else { printk(KERN_ERR "ACPI does not support this state: %d\n", pm_state); - error = -ENOSYS; } return error; } _______________________________________________ linux-pm mailing list linux-pm@xxxxxxxxxxxxxxxxxxxxxxxxxx https://lists.linux-foundation.org/mailman/listinfo/linux-pm