Skip to content

platform/surface: platform_profile: fix uninitialized return in pm_prepare - #197

Merged
qzed merged 1 commit into
linux-surface:v7.3-surfacefrom
larsschellhas:fix-pm-prepare-uninit-status
Nov 16, 2026
Merged

qzed merged 1 commit into
linux-surface:v7.3-surfacefrom
larsschellhas:fix-pm-prepare-uninit-status

Conversation

@larsschellhas

Copy link
Copy Markdown
Contributor

surface_platform_profile_pm_prepare() (added in #166) only assigns status inside if (tpd->has_fan). On devices without the has_fan property it returns an uninitialized value, so the PM core aborts every suspend with not prepared for power transition: code <random negative number>:

surface_platform_profile 01:03:01:00:01: PM: device_prepare(): surface_platform_profile_pm_prepare [surface_platform_profile] returns -958946816
surface_platform_profile 01:03:01:00:01: PM: not prepared for power transition: code -958946816

Fix: initialize status = 0.

Fixes linux-surface/linux-surface#2386

Tested on a Surface Book 3, 7.3.4-1-surface, with the patched module loaded via insmod: 3 of 3 systemctl suspend attempts (s2idle, RTC wake after 25 s) entered and left suspend with no not prepared for power transition message. Without the patch, 93 of 94 attempts since 2026-11-15 failed with it.

Note (not part of the fix): as written, a failing fan-standby call also aborts suspend. If that is not intended, returning 0 after the dev_err() would be more forgiving.

…epare

surface_platform_profile_pm_prepare() declares "int status;" without an
initializer and only assigns it inside the "if (tpd->has_fan)" block.
On devices where the "has_fan" property is not set, such as the Surface
Pro 7 and the Surface Book 3, the function returns whatever happens to be
on the stack. Any non-zero value makes the PM core abort the transition:

  surface_platform_profile 01:03:01:00:01: PM: device_prepare():
    surface_platform_profile_pm_prepare [surface_platform_profile]
    returns -1050009088
  surface_platform_profile 01:03:01:00:01: PM: not prepared for power
    transition: code -1050009088
  PM: Some devices failed to suspend, or early wake event detected

and the machine immediately resumes instead of suspending.

Initialize status to 0 so that devices without a fan report success.

Fixes: 743c726 ("platform/surface: platform_profile: add fan power state handling")
Signed-off-by: Lars Schellhas van Kisfeld <lars.schellhas-van-kisfeld@schellhasconsulting.de>

@qzed qzed left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@qzed
qzed merged commit 69f92d1 into linux-surface:v7.3-surface Nov 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants