Skip to content

Commit e20a70c

Browse files
ISCAS-Vulabrafaeljw
authored andcommitted
PM: hibernate: Add error handling for syscore_suspend()
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: 40dc166 ("PM / Core: Introduce struct syscore_ops for core subsystems PM") Signed-off-by: Wentao Liang <[email protected]> Link: https://patch.msgid.link/[email protected] [ rjw: Changelog edits ] Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent f4b9d3b commit e20a70c

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

kernel/power/hibernate.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -608,7 +608,11 @@ int hibernation_platform_enter(void)
608608

609609
local_irq_disable();
610610
system_state = SYSTEM_SUSPEND;
611-
syscore_suspend();
611+
612+
error = syscore_suspend();
613+
if (error)
614+
goto Enable_irqs;
615+
612616
if (pm_wakeup_pending()) {
613617
error = -EAGAIN;
614618
goto Power_up;
@@ -620,6 +624,7 @@ int hibernation_platform_enter(void)
620624

621625
Power_up:
622626
syscore_resume();
627+
Enable_irqs:
623628
system_state = SYSTEM_RUNNING;
624629
local_irq_enable();
625630

0 commit comments

Comments
 (0)