Skip to content

Commit d9c7fe3

Browse files
ISCAS-VulabSherryYang1
authored andcommitted
PM: hibernate: Add error handling for syscore_suspend()
[ Upstream commit e20a70c ] 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]> Signed-off-by: Sasha Levin <[email protected]> (cherry picked from commit a51dedd5861c40e7651ee37bf31153a80135edb5) Signed-off-by: Sherry Yang <[email protected]>
1 parent 092c24e commit d9c7fe3

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
@@ -590,7 +590,11 @@ int hibernation_platform_enter(void)
590590

591591
local_irq_disable();
592592
system_state = SYSTEM_SUSPEND;
593-
syscore_suspend();
593+
594+
error = syscore_suspend();
595+
if (error)
596+
goto Enable_irqs;
597+
594598
if (pm_wakeup_pending()) {
595599
error = -EAGAIN;
596600
goto Power_up;
@@ -602,6 +606,7 @@ int hibernation_platform_enter(void)
602606

603607
Power_up:
604608
syscore_resume();
609+
Enable_irqs:
605610
system_state = SYSTEM_RUNNING;
606611
local_irq_enable();
607612

0 commit comments

Comments
 (0)