summaryrefslogtreecommitdiff
path: root/kernel
diff options
context:
space:
mode:
authorWentao Liang <vulab@iscas.ac.cn>2025-01-19 22:32:05 +0800
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2025-02-08 09:58:03 +0100
commit3b732c60a00c3390ec84ea5246350d556fb16ddd (patch)
tree2f65a0e2b06a9898b81f4d38a2f5199a2507d5b7 /kernel
parenta099834a51ccf9bbba3de86a251b3433539abfde (diff)
downloadlinux-3b732c60a00c3390ec84ea5246350d556fb16ddd.tar.gz
linux-3b732c60a00c3390ec84ea5246350d556fb16ddd.tar.bz2
linux-3b732c60a00c3390ec84ea5246350d556fb16ddd.zip
PM: hibernate: Add error handling for syscore_suspend()
[ Upstream commit e20a70c572539a486dbd91b225fa6a194a5e2122 ] In hibernation_platform_enter(), the code did not check the return value of syscore_suspend(), potentially leading to a situation where syscore_resume() would be called even if syscore_suspend() failed. This could cause unpredictable behavior or system instability. Modify the code sequence in question to properly handle errors returned by syscore_suspend(). If an error occurs in the suspend path, the code now jumps to label 'Enable_irqs' skipping the syscore_resume() call and only enabling interrupts after setting the system state to SYSTEM_RUNNING. Fixes: 40dc166cb5dd ("PM / Core: Introduce struct syscore_ops for core subsystems PM") Signed-off-by: Wentao Liang <vulab@iscas.ac.cn> Link: https://patch.msgid.link/20250119143205.2103-1-vulab@iscas.ac.cn [ rjw: Changelog edits ] Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/power/hibernate.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/kernel/power/hibernate.c b/kernel/power/hibernate.c
index e35829d36039..b483fcea811b 100644
--- a/kernel/power/hibernate.c
+++ b/kernel/power/hibernate.c
@@ -608,7 +608,11 @@ int hibernation_platform_enter(void)
local_irq_disable();
system_state = SYSTEM_SUSPEND;
- syscore_suspend();
+
+ error = syscore_suspend();
+ if (error)
+ goto Enable_irqs;
+
if (pm_wakeup_pending()) {
error = -EAGAIN;
goto Power_up;
@@ -620,6 +624,7 @@ int hibernation_platform_enter(void)
Power_up:
syscore_resume();
+ Enable_irqs:
system_state = SYSTEM_RUNNING;
local_irq_enable();