Message ID | 20250119143205.2103-1-vulab@iscas.ac.cn |
---|---|
State | New |
Headers | show |
Series | PM: hibernate: Add error handling for syscore_suspend() | expand |
diff --git a/kernel/power/hibernate.c b/kernel/power/hibernate.c index 1f87aa01ba44..8e5702811732 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();
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. This commit modifies the suspend/resume sequence to properly handle errors returned by syscore_suspend(). If an error occurs during the suspend process, the code now jumps to 'Enable_irqs' label, skipping the 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> --- kernel/power/hibernate.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)