* [PATCH AUTOSEL 6.15 07/21] mailbox: Not protect module_put with spin_lock_irqsave
[not found] <20250606154147.546388-1-sashal@kernel.org>
@ 2025-06-06 15:41 ` Sasha Levin
2025-06-06 15:41 ` [PATCH AUTOSEL 6.15 09/21] mfd: max14577: Fix wakeup source leaks on device unbind Sasha Levin
2025-06-06 15:41 ` [PATCH AUTOSEL 6.15 10/21] mfd: max77705: " Sasha Levin
2 siblings, 0 replies; 3+ messages in thread
From: Sasha Levin @ 2025-06-06 15:41 UTC (permalink / raw)
To: patches, stable; +Cc: Peng Fan, Jassi Brar, Sasha Levin, linux-kernel
From: Peng Fan <peng.fan@nxp.com>
[ Upstream commit dddbd233e67e792bb0a3f9694a4707e6be29b2c6 ]
&chan->lock is not supposed to protect 'chan->mbox'.
And in __mbox_bind_client, try_module_get is also not protected
by &chan->lock. So move module_put out of the lock protected
region.
Signed-off-by: Peng Fan <peng.fan@nxp.com>
Signed-off-by: Jassi Brar <jassisinghbrar@gmail.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
**YES** This commit should be backported to stable kernel trees.
**Analysis:** 1. **Clear Bug Fix**: The commit fixes an improper use of
`module_put()` under a spinlock in `mbox_free_channel()`. Looking at the
current code in `/home/sasha/linux/drivers/mailbox/mailbox.c:489`,
`module_put()` is called while holding `&chan->lock` with
`spin_lock_irqsave()`. 2. **Locking Inconsistency**: The commit message
correctly identifies that `&chan->lock` is not supposed to protect
`chan->mbox`. In `__mbox_bind_client()` (line 324),
`try_module_get(chan->mbox->dev->driver->owner)` is called **outside**
the spinlock protection, making the current `module_put()` placement
inconsistent. 3. **Minimal Risk Change**: The fix is extremely simple
and low-risk - it just moves one line (`module_put()`) outside the
spinlock region. This maintains the same operation order but fixes the
locking issue. 4. **No Side Effects**: Moving `module_put()` outside the
lock doesn't change the functionality or introduce new race conditions.
The `module_put()` implementation uses `atomic_dec_if_positive()`, so
it's safe to call without additional locking. 5. **Follows Stable
Rules**: This commit: - Fixes a real locking issue that could
potentially cause problems - Is small and contained (single line move) -
Has minimal regression risk - Doesn't introduce new features or
architectural changes 6. **Similar Pattern**: Looking at similar commits
in the historical references, commits that fix locking issues (like
Similar Commit #5 which fixed a locking bug in mailbox-test) were marked
as YES for backporting. The commit addresses a legitimate kernel locking
violation where `module_put()` should not be called under a spinlock,
making it a suitable candidate for stable tree backporting.
drivers/mailbox/mailbox.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/mailbox/mailbox.c b/drivers/mailbox/mailbox.c
index 0593b4d036859..aea0e690b63ee 100644
--- a/drivers/mailbox/mailbox.c
+++ b/drivers/mailbox/mailbox.c
@@ -486,8 +486,8 @@ void mbox_free_channel(struct mbox_chan *chan)
if (chan->txdone_method == TXDONE_BY_ACK)
chan->txdone_method = TXDONE_BY_POLL;
- module_put(chan->mbox->dev->driver->owner);
spin_unlock_irqrestore(&chan->lock, flags);
+ module_put(chan->mbox->dev->driver->owner);
}
EXPORT_SYMBOL_GPL(mbox_free_channel);
--
2.39.5
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH AUTOSEL 6.15 09/21] mfd: max14577: Fix wakeup source leaks on device unbind
[not found] <20250606154147.546388-1-sashal@kernel.org>
2025-06-06 15:41 ` [PATCH AUTOSEL 6.15 07/21] mailbox: Not protect module_put with spin_lock_irqsave Sasha Levin
@ 2025-06-06 15:41 ` Sasha Levin
2025-06-06 15:41 ` [PATCH AUTOSEL 6.15 10/21] mfd: max77705: " Sasha Levin
2 siblings, 0 replies; 3+ messages in thread
From: Sasha Levin @ 2025-06-06 15:41 UTC (permalink / raw)
To: patches, stable
Cc: Krzysztof Kozlowski, Lee Jones, Sasha Levin, cw00.choi, krzk,
linux-kernel
From: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
[ Upstream commit d905d06e64b0eb3da43af6186c132f5282197998 ]
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-3-318e14bdba0a@linaro.org
Signed-off-by: Lee Jones <lee@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
Now let me understand the difference between the fixes - the historical
commits show two patterns:
1. Using `devm_device_init_wakeup()` - automatically handles cleanup
2. Manual cleanup by calling `device_init_wakeup(dev, false)` in remove
functions
Let me check if this specific commit has `Cc: stable@vger.kernel.org` in
the message:
Based on my analysis of this commit and comparison with the similar
historical commits, here is my assessment:
**YES**
This commit should be backported to stable kernel trees for the
following reasons:
## Analysis
### **Code Change Analysis**
The commit adds a single line in the `max14577_i2c_remove()` function:
```c
+ device_init_wakeup(max14577->dev, false);
```
This addition occurs at drivers/mfd/max14577.c:459, right before
`mfd_remove_devices()` is called.
### **Bug Fix Characteristics**
1. **Memory Leak Fix**: The commit fixes a wakeup source memory leak
that occurs when the device is unbound. When `device_init_wakeup(dev,
true)` is called during probe (line 442), it allocates memory for
wakeup source structures. Without the corresponding cleanup call,
this memory is leaked on device removal.
2. **Small and Contained**: The fix is minimal - a single line addition
that mirrors the cleanup pattern used throughout the kernel.
3. **Low Risk**: The change has extremely low regression risk since it
only adds proper cleanup that should have been there originally.
### **Comparison with Historical Similar Commits**
Looking at the provided historical commits, there are two categories:
**YES commits (backported)**:
- `gpio: mpc8xxx: Fix wakeup source leaks on device unbind` - Same exact
pattern and includes `Cc: stable@vger.kernel.org`
- `gpio: zynq: Fix wakeup source leaks on device unbind` - Same exact
pattern and includes `Cc: stable@vger.kernel.org`
**NO commits (not backported)**:
- IIO driver commits that use `devm_device_init_wakeup()` instead of
manual cleanup
The key difference is that the YES commits use the same fix pattern as
this MFD commit - manual cleanup in the remove function, while the NO
commits use the `devm_` managed approach that automatically handles
cleanup.
### **Impact Assessment**
- **User Impact**: Memory leaks on device unbind affect systems where
MFD devices are frequently bound/unbound
- **Subsystem**: MFD (Multi-Function Device) is a core kernel subsystem
used by many embedded systems
- **Regression Risk**: Minimal - adding proper cleanup cannot cause
functional regression
### **Stable Tree Criteria Met**
1. ✅ Fixes an important bug (memory leak)
2. ✅ Small and contained change
3. ✅ No architectural changes
4. ✅ Minimal risk of regression
5. ✅ Follows established patterns seen in other backported commits
The commit follows the exact same pattern as the GPIO driver commits
that were successfully backported to stable trees (commits #1 and #2 in
the historical examples), making it a clear candidate for backporting.
drivers/mfd/max14577.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/mfd/max14577.c b/drivers/mfd/max14577.c
index 6fce79ec2dc64..7e7e8af9af224 100644
--- a/drivers/mfd/max14577.c
+++ b/drivers/mfd/max14577.c
@@ -456,6 +456,7 @@ static void max14577_i2c_remove(struct i2c_client *i2c)
{
struct max14577 *max14577 = i2c_get_clientdata(i2c);
+ device_init_wakeup(max14577->dev, false);
mfd_remove_devices(max14577->dev);
regmap_del_irq_chip(max14577->irq, max14577->irq_data);
if (max14577->dev_type == MAXIM_DEVICE_TYPE_MAX77836)
--
2.39.5
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH AUTOSEL 6.15 10/21] mfd: max77705: Fix wakeup source leaks on device unbind
[not found] <20250606154147.546388-1-sashal@kernel.org>
2025-06-06 15:41 ` [PATCH AUTOSEL 6.15 07/21] mailbox: Not protect module_put with spin_lock_irqsave Sasha Levin
2025-06-06 15:41 ` [PATCH AUTOSEL 6.15 09/21] mfd: max14577: Fix wakeup source leaks on device unbind Sasha Levin
@ 2025-06-06 15:41 ` Sasha Levin
2 siblings, 0 replies; 3+ messages in thread
From: Sasha Levin @ 2025-06-06 15:41 UTC (permalink / raw)
To: patches, stable
Cc: Krzysztof Kozlowski, Lee Jones, Sasha Levin, cw00.choi, krzk,
linux-kernel
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@linaro.org
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;
}
--
2.39.5
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-06-06 15:42 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20250606154147.546388-1-sashal@kernel.org>
2025-06-06 15:41 ` [PATCH AUTOSEL 6.15 07/21] mailbox: Not protect module_put with spin_lock_irqsave Sasha Levin
2025-06-06 15:41 ` [PATCH AUTOSEL 6.15 09/21] mfd: max14577: Fix wakeup source leaks on device unbind Sasha Levin
2025-06-06 15:41 ` [PATCH AUTOSEL 6.15 10/21] mfd: max77705: " Sasha Levin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).