Thread (1 message) 1 message, 1 author, 2025-06-04
STALE423d

[PATCH AUTOSEL 6.14 013/108] Bluetooth: btmrvl_sdio: Fix wakeup source leaks on device unbind

From: Sasha Levin <sashal@kernel.org>
Date: 2025-06-04 00:55:54
Also in: linux-patches, stable
Subsystem: bluetooth drivers, the rest · Maintainers: Marcel Holtmann, Luiz Augusto von Dentz, Linus Torvalds

From: Krzysztof Kozlowski <redacted>

[ Upstream commit ba6535e8b494931471df9666addf0f1e5e6efa27 ]

Device can be unbound or probe can fail, so driver must also release
memory for the wakeup source.

Signed-off-by: Krzysztof Kozlowski <redacted>
Signed-off-by: Luiz Augusto von Dentz <redacted>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---

**YES** This commit should be backported to stable kernel trees. Here's
my extensive analysis: ## Analysis of the Commit ### 1. Nature of the
Fix This commit addresses a **resource leak bug** in the btmrvl_sdio
driver. The fix changes `device_init_wakeup(dev, true)` to
`devm_device_init_wakeup(dev)`, which ensures automatic cleanup of
wakeup sources when the device is unbound or probe fails. ### 2. Code
Changes Analysis The specific changes are: ```diff -
device_init_wakeup(dev, true); + ret = devm_device_init_wakeup(dev); +
if (ret) + return dev_err_probe(dev, ret, "Failed to init wakeup\n");
``` This change: - Replaces manual wakeup initialization with device-
managed version - Adds proper error handling for the wakeup
initialization - Ensures automatic cleanup when device is removed or
probe fails ### 3. Comparison with Similar Commits This commit is **very
similar to Similar Commit #3** (gpio: mpc8xxx), which: - Also fixes
wakeup source leaks on device unbind - Uses the same pattern:
`device_init_wakeup()` → `devm_device_init_wakeup()` - Has identical
commit message structure and purpose - **Was marked for backporting
(Status: YES)** The pattern is also similar to **Similar Commit #2**
(btmrvl_sdio: Refactor irq wakeup), which was also backported (Status:
YES) and dealt with wakeup handling improvements. ### 4. Stable Tree
Criteria Assessment ✅ **Fixes important bug**: Resource leaks can cause
system-wide issues ✅ **Small and contained**: Only changes 3 lines in
one function ✅ **No architectural changes**: Uses existing kernel APIs ✅
**Minimal regression risk**: Device-managed resources are well-
established ✅ **Clear side effects**: Only improves resource management
✅ **Affects users**: Anyone using btmrvl_sdio with wakeup functionality
### 5. Risk Analysis **Low Risk Factors:** - `devm_device_init_wakeup()`
is a well-established API - The change follows standard kernel patterns
for resource management - Error handling is improved with proper error
propagation - Similar changes have been successfully backported (as
shown in Similar Commit #3) **No Major Concerns:** - No changes to
critical code paths - No new features introduced - No complex logic
modifications ### 6. Impact Assessment **Positive Impact:** - Prevents
wakeup source memory leaks - Improves system stability during device
unbind/rebind cycles - Follows kernel best practices for resource
management - Adds better error handling **User-Facing Benefit:** -
Systems using btmrvl_sdio devices will be more stable - Proper cleanup
during module unload or device removal - Better error reporting if
wakeup initialization fails ### Conclusion This commit meets all the
criteria for stable backporting: - It's a clear bugfix addressing
resource leaks - The change is minimal and low-risk - It follows
established patterns (identical to Similar Commit #3 which was
backported) - It improves system stability without introducing new
functionality - The fix is contained within a single driver subsystem
The commit should be backported to ensure users don't experience wakeup
source leaks when using btmrvl_sdio devices.

 drivers/bluetooth/btmrvl_sdio.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/bluetooth/btmrvl_sdio.c b/drivers/bluetooth/btmrvl_sdio.c
index 07cd308f7abf6..93932a0d8625a 100644
--- a/drivers/bluetooth/btmrvl_sdio.c
+++ b/drivers/bluetooth/btmrvl_sdio.c
@@ -100,7 +100,9 @@ static int btmrvl_sdio_probe_of(struct device *dev,
 			}
 
 			/* Configure wakeup (enabled by default) */
-			device_init_wakeup(dev, true);
+			ret = devm_device_init_wakeup(dev);
+			if (ret)
+				return dev_err_probe(dev, ret, "Failed to init wakeup\n");
 		}
 	}
 
-- 
2.39.5
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help