From: Krzysztof Kozlowski krzysztof.kozlowski@linaro.org
[ Upstream commit 6d0b2398b2638208d68ba06601f776cd5d983b75 ]
Device can be unbound, so driver must also release memory for the wakeup source.
Signed-off-by: Krzysztof Kozlowski krzysztof.kozlowski@linaro.org Reviewed-by: Karel Balej balejk@matfyz.cz Link: https://lore.kernel.org/r/20250406-mfd-device-wakekup-leak-v1-1-318e14bdba0a... Signed-off-by: Lee Jones lee@kernel.org Signed-off-by: Sasha Levin sashal@kernel.org ---
**YES**
This commit should be backported to stable kernel trees based on the following analysis:
## Code Change Analysis
The commit changes lines 127-128 in `drivers/mfd/88pm886.c` from: ```c device_init_wakeup(dev, device_property_read_bool(dev, "wakeup- source")); ```
To: ```c if (device_property_read_bool(dev, "wakeup-source")) { err = devm_device_init_wakeup(dev); if (err) return dev_err_probe(dev, err, "Failed to init wakeup\n"); } ```
## Why This Should Be Backported
**1. Clear Bug Fix**: This fixes a definitive memory leak where wakeup source memory is not properly freed when the device is unbound. The `device_init_wakeup()` function allocates memory that requires manual cleanup, while `devm_device_init_wakeup()` uses the device-managed resource framework to automatically clean up.
**2. Matches Successful Backport Pattern**: This change follows the exact same pattern as Similar Commits #1 and #2 (gpio drivers) which were marked "Backport Status: YES". The fix uses identical methodology - replacing `device_init_wakeup()` with `devm_device_init_wakeup()` and proper error handling.
**3. Low Risk, High Benefit**: - **Risk**: Minimal - only affects error handling path and uses well- established devm pattern - **Benefit**: Eliminates memory leak without changing functional behavior - **Size**: Small, contained change with no architectural implications
**4. Stable Tree Compliance**: - ✅ Fixes important bug (memory leak) - ✅ No new features introduced - ✅ No architectural changes - ✅ Minimal regression risk - ✅ Confined to single driver
**5. Critical System Impact**: The 88PM886 is a Power Management IC used in embedded devices. While not immediately critical, memory leaks in power management components can accumulate over time in long-running embedded systems.
**6. Consistent with Kernel-wide Effort**: The commit is part of a broader kernel-wide cleanup to fix wakeup source leaks, with similar fixes already being backported to stable trees across multiple subsystems (GPIO, IIO, etc.).
The change is technically sound, follows established patterns, and addresses a real resource leak with minimal risk - making it an ideal candidate for stable tree backporting.
drivers/mfd/88pm886.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/mfd/88pm886.c b/drivers/mfd/88pm886.c index 891fdce5d8c12..177878aa32f86 100644 --- a/drivers/mfd/88pm886.c +++ b/drivers/mfd/88pm886.c @@ -124,7 +124,11 @@ static int pm886_probe(struct i2c_client *client) if (err) return dev_err_probe(dev, err, "Failed to register power off handler\n");
- device_init_wakeup(dev, device_property_read_bool(dev, "wakeup-source")); + if (device_property_read_bool(dev, "wakeup-source")) { + err = devm_device_init_wakeup(dev); + if (err) + return dev_err_probe(dev, err, "Failed to init wakeup\n"); + }
return 0; }