Skip to content

Commit

Permalink
PM: suspend: Fix platform_suspend_prepare_noirq()
Browse files Browse the repository at this point in the history
After commit ac9eafb ("ACPI: PM: s2idle: Execute LPS0 _DSM
functions with suspended devices"), a NULL pointer may be dereferenced
if suspend-to-idle is attempted on a platform without "traditional"
suspend support due to invalid fall-through in
platform_suspend_prepare_noirq().

Fix that and while at it add missing braces in platform_resume_noirq().

Fixes: ac9eafb ("ACPI: PM: s2idle: Execute LPS0 _DSM functions with suspended devices")
Reported-by: Marek Szyprowski <[email protected]>
Signed-off-by: Rafael J. Wysocki <[email protected]>
  • Loading branch information
rafaeljw committed Aug 10, 2019
1 parent d19bdb8 commit 11f2663
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions kernel/power/suspend.c
Original file line number Diff line number Diff line change
Expand Up @@ -253,10 +253,10 @@ static int platform_suspend_prepare_late(suspend_state_t state)

static int platform_suspend_prepare_noirq(suspend_state_t state)
{
if (state == PM_SUSPEND_TO_IDLE) {
if (s2idle_ops && s2idle_ops->prepare_late)
return s2idle_ops->prepare_late();
}
if (state == PM_SUSPEND_TO_IDLE)
return s2idle_ops && s2idle_ops->prepare_late ?
s2idle_ops->prepare_late() : 0;

return suspend_ops->prepare_late ? suspend_ops->prepare_late() : 0;
}

Expand All @@ -265,8 +265,9 @@ static void platform_resume_noirq(suspend_state_t state)
if (state == PM_SUSPEND_TO_IDLE) {
if (s2idle_ops && s2idle_ops->restore_early)
s2idle_ops->restore_early();
} else if (suspend_ops->wake)
} else if (suspend_ops->wake) {
suspend_ops->wake();
}
}

static void platform_resume_early(suspend_state_t state)
Expand Down

0 comments on commit 11f2663

Please sign in to comment.