From: Krzysztof Kozlowski krzysztof.kozlowski@linaro.org
[ Upstream commit a59a56cc4fb1f7d101f7ce1f5396ceaa2e304b71 ]
Device can be unbound, so driver must also release memory for the wakeup source.
Signed-off-by: Krzysztof Kozlowski krzysztof.kozlowski@linaro.org Link: https://lore.kernel.org/r/20250406-mfd-device-wakekup-leak-v1-5-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. Here's my extensive analysis:
## Code Change Analysis
The commit changes line 134 in `drivers/mfd/max77705.c` from: ```c device_init_wakeup(dev, true); ``` to: ```c ret = devm_device_init_wakeup(dev); if (ret) return dev_err_probe(dev, ret, "Failed to init wakeup\n"); ```
This is a classic **resource leak fix** pattern where the driver was using `device_init_wakeup()` without proper cleanup on device unbind, which causes memory leaks for the wakeup source.
## Backport Suitability Assessment
### 1. **Fixes a Real Bug**: ✅ YES - This fixes a memory leak that occurs when devices are unbound from the driver - The wakeup source memory is not released without proper cleanup - This affects real user scenarios where devices can be unbound/rebound
### 2. **Small and Contained Change**: ✅ YES - Only 3 lines changed: 1 deletion, 2 additions - Single function modification in probe path - No architectural changes whatsoever - Extremely localized to wakeup source initialization
### 3. **Low Risk of Regression**: ✅ YES - `devm_device_init_wakeup()` is a well-established managed resource pattern - Same functionality as original but with automatic cleanup - The change follows standard kernel resource management patterns - No behavior change except proper cleanup
### 4. **Pattern Consistency**: ✅ YES From the git history analysis, I found this is part of a systematic fix series by Krzysztof Kozlowski addressing the same issue across multiple subsystems: - `gpio: mpc8xxx: Fix wakeup source leaks` - **marked with Cc: stable@vger.kernel.org** - `gpio: zynq: Fix wakeup source leaks` - **marked with Cc: stable@vger.kernel.org** - Similar fixes in iio, watchdog, mfd subsystems with identical patterns
### 5. **Critical Subsystem**: ✅ YES - MFD (Multi-Function Device) drivers are core platform drivers - MAX77705 is a PMIC (Power Management IC) used in mobile devices - Resource leaks in power management components can lead to system instability
### 6. **Stable Tree Compatibility**: ✅ YES - The `devm_device_init_wakeup()` function has been available since early kernel versions - No new API dependencies - The fix pattern is well-established and widely used
### 7. **Related Evidence**: The companion commits in the same series (`gpio: mpc8xxx` and `gpio: zynq`) were **explicitly tagged with `Cc: stable@vger.kernel.org`**, indicating the author and maintainers consider this class of fix appropriate for stable backporting.
**Conclusion**: This is a textbook stable candidate - a small, safe resource leak fix that addresses a real problem with minimal risk and follows established patterns that have been deemed stable-worthy in the same patch series.
drivers/mfd/max77705.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/mfd/max77705.c b/drivers/mfd/max77705.c index 60c457c21d952..6b263bacb8c28 100644 --- a/drivers/mfd/max77705.c +++ b/drivers/mfd/max77705.c @@ -131,7 +131,9 @@ static int max77705_i2c_probe(struct i2c_client *i2c) if (ret) return dev_err_probe(dev, ret, "Failed to register child devices\n");
- device_init_wakeup(dev, true); + ret = devm_device_init_wakeup(dev); + if (ret) + return dev_err_probe(dev, ret, "Failed to init wakeup\n");
return 0; }