diff options
| author | Guenter Roeck <linux@roeck-us.net> | 2026-11-05 10:17:02 -0800 |
|---|---|---|
| committer | Guenter Roeck <linux@roeck-us.net> | 2026-11-08 17:45:31 -0800 |
| commit | 221b565a3316b1ba3a9bcd1f61238440207b3e00 (patch) | |
| tree | 5231c942d01fe4880975564c974a961e7878a209 /scripts/Makefile.thinlto | |
| parent | 7475ea8b58616b33c04afb976cf0fbaad9dd63fb (diff) | |
hwmon: (gpio-fan) Fix runtime PM imbalance in probe and teardown
In gpio_fan_probe(), gpio_fan_stop() is registered conditionally as a
devres action before runtime PM is initialized, while gpio_fan_stop()
unconditionally calls pm_runtime_disable(). This breaks runtime PM
disable_depth and usage_count invariants across several paths:
- On alarm-only devices without control GPIOs, gpio_fan_stop() is never
registered, leaving pm_runtime_enable() unbalanced on unbind and
triggering "Unbalanced pm_runtime_enable!" on subsequent binds.
- When control GPIOs are present and devm_add_action_or_reset(), hwmon
registration, or fan_alarm_init() fails, gpio_fan_stop() runs before
pm_runtime_enable(), incrementing disable_depth to 2 (leaving runtime
PM permanently disabled on re-probe) and, if speed_index > 0,
underflowing usage_count via pm_runtime_put_sync().
- If pm_runtime_resume_and_get() fails when speed_index > 0, it drops
its reference while speed_index remains non-zero, causing
gpio_fan_stop() to call pm_runtime_put_sync() and underflow
usage_count.
- Registering the hwmon device before enabling runtime PM exposes sysfs
attributes that can invoke set_fan_speed() before runtime PM state is
initialized.
Initialize runtime PM upfront with pm_runtime_set_suspended() and
devm_pm_runtime_enable(), remove pm_runtime_disable() from
gpio_fan_stop(), and acquire the initial active runtime PM reference
before registering gpio_fan_stop() and the hwmon device.
Fixes: 0d01110e6356 ("hwmon: (gpio-fan) Add regulator support")
Reported-by: Sashiko <sashiko@sashiko.dev>
Link: https://sashiko.dev/#/bug/linux-349aa3ba-30c3-4c3c-b47e-f52839af2b8d
Cc: stable@vger.kernel.org
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Diffstat (limited to 'scripts/Makefile.thinlto')
0 files changed, 0 insertions, 0 deletions
