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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Krzysztof Kozlowski <krzysztof.kozlowski@xxxxxxxxxx>

[ 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 <krzysztof.kozlowski@xxxxxxxxxx>
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@xxxxxxxxx>
Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>
---

**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





[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux