Skip to content

Commit

Permalink
PM: hibernate: Add error handling for syscore_suspend()
Browse files Browse the repository at this point in the history
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 <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>
  • Loading branch information
Wentao Liang authored and Rafael J. Wysocki committed Jan 23, 2025
1 parent f4b9d3b commit e20a70c
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion kernel/power/hibernate.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -620,6 +624,7 @@ int hibernation_platform_enter(void)

Power_up:
syscore_resume();
Enable_irqs:
system_state = SYSTEM_RUNNING;
local_irq_enable();

Expand Down

0 comments on commit e20a70c

Please sign in to comment.