From: Sasha Levin <sashal@kernel.org>
To: patches@lists.linux.dev, stable@vger.kernel.org
Cc: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>,
Luiz Augusto von Dentz <luiz.von.dentz@intel.com>,
Sasha Levin <sashal@kernel.org>,
marcel@holtmann.org, luiz.dentz@gmail.com,
matthias.bgg@gmail.com, angelogioacchino.delregno@collabora.com,
linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-mediatek@lists.infradead.org
Subject: [PATCH AUTOSEL 6.15 014/118] Bluetooth: btmtksdio: Fix wakeup source leaks on device unbind
Date: Tue, 3 Jun 2025 20:49:05 -0400 [thread overview]
Message-ID: <20250604005049.4147522-14-sashal@kernel.org> (raw)
In-Reply-To: <20250604005049.4147522-1-sashal@kernel.org>
From: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
[ Upstream commit ee3e4209e66d44180a41d5ca7271361a2a28fccf ]
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@linaro.org>
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
**YES** This commit should be backported to stable kernel trees. Here's
my extensive analysis: ## Detailed Analysis ### 1. Nature of the Bug
This is a **resource leak fix** that addresses a memory leak in wakeup
source management. The change from `device_init_wakeup(bdev->dev, true)`
to `devm_device_init_wakeup(bdev->dev)` is critical because: - **Manual
management risk**: The original code manually enables wakeup capability
but has no corresponding cleanup in the remove path - **Automatic
cleanup**: The new `devm_device_init_wakeup()` uses the device resource
management framework to automatically clean up wakeup sources when the
device is unbound ### 2. Impact and Severity **Memory leak occurs
when:** - Device is unbound/removed - Driver probe fails after wakeup
initialization - System module unloading **What gets leaked:** - `struct
wakeup_source` structures (~200 bytes each) - Associated name strings
and metadata - Debugfs entries - IDA allocations for unique IDs ### 3.
Pattern Recognition from Similar Commits Looking at the historical
similar commits provided, I can see this is part of a **systematic
kernel-wide fix campaign**: - **Commits #4 and #5** (gpio-zynq and gpio-
mpc8xxx) show identical patterns with "Backport Status: YES" - **Commits
#1, #2, #3** are feature additions/improvements with "Backport Status:
NO" The gpio commits demonstrate this exact same fix pattern being
deemed appropriate for stable backporting. ### 4. Code Analysis The fix
is **minimal and contained**: ```c - err = device_init_wakeup(bdev->dev,
true); + err = devm_device_init_wakeup(bdev->dev); ``` **Risk
assessment:** - **Very low regression risk**:
`devm_device_init_wakeup()` is a simple wrapper that adds automatic
cleanup - **No functional changes**: Same wakeup behavior, just proper
resource management - **Well-tested pattern**: Same fix applied across
multiple kernel subsystems ### 5. Stable Tree Criteria Compliance ✅
**Fixes important bug**: Resource leaks can lead to memory exhaustion ✅
**Small and contained**: Single line change ✅ **Clear side effects**:
None beyond fixing the leak ✅ **No architectural changes**: Pure
resource management improvement ✅ **Minimal regression risk**: Uses
established devres patterns ✅ **Author expertise**: Krzysztof Kozlowski
is a well-known kernel maintainer ### 6. Driver Importance The btmtksdio
driver supports MediaTek Bluetooth SDIO devices, which are widely used
in: - Android smartphones and tablets - IoT devices - Embedded systems -
Consumer electronics Device unbinding is common during: - System
suspend/resume cycles - Module loading/unloading - Device hotplug
scenarios - Driver updates ### 7. Comparison with Reference Commits This
commit closely matches the **"YES"** examples (commits #4 and #5): -
Same author (Krzysztof Kozlowski) - Identical fix pattern
(`device_init_wakeup` → `devm_device_init_wakeup`) - Same commit message
structure - Same Cc: stable@vger.kernel.org tag - Same resource leak
issue being addressed **Conclusion**: This is a straightforward resource
leak fix that follows established patterns for stable tree backporting.
The risk is minimal while the benefit is clear - preventing memory leaks
that could lead to system instability over time.
drivers/bluetooth/btmtksdio.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/bluetooth/btmtksdio.c b/drivers/bluetooth/btmtksdio.c
index 1d26207b2ba70..c16a3518b8ffa 100644
--- a/drivers/bluetooth/btmtksdio.c
+++ b/drivers/bluetooth/btmtksdio.c
@@ -1414,7 +1414,7 @@ static int btmtksdio_probe(struct sdio_func *func,
*/
pm_runtime_put_noidle(bdev->dev);
- err = device_init_wakeup(bdev->dev, true);
+ err = devm_device_init_wakeup(bdev->dev);
if (err)
bt_dev_err(hdev, "failed to initialize device wakeup");
--
2.39.5
next prev parent reply other threads:[~2025-06-04 0:51 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20250604005049.4147522-1-sashal@kernel.org>
2025-06-04 0:48 ` [PATCH AUTOSEL 6.15 008/118] wifi: mt76: mt7996: drop fragments with multicast or broadcast RA Sasha Levin
2025-06-04 0:49 ` [PATCH AUTOSEL 6.15 010/118] Bluetooth: btusb: Add new VID/PID 13d3/3630 for MT7925 Sasha Levin
2025-06-04 0:49 ` Sasha Levin [this message]
2025-06-04 0:49 ` [PATCH AUTOSEL 6.15 015/118] wifi: mt76: mt7996: fix uninitialized symbol warning Sasha Levin
2025-06-04 0:49 ` [PATCH AUTOSEL 6.15 016/118] wifi: mt76: mt76x2: Add support for LiteOn WN4516R,WN4519R Sasha Levin
2025-06-04 0:49 ` [PATCH AUTOSEL 6.15 017/118] wifi: mt76: mt7921: add 160 MHz AP for mt7922 device Sasha Levin
2025-06-04 0:49 ` [PATCH AUTOSEL 6.15 018/118] wifi: mt76: mt7925: introduce thermal protection Sasha Levin
2025-06-04 0:49 ` [PATCH AUTOSEL 6.15 029/118] net: phy: mediatek: do not require syscon compatible for pio property Sasha Levin
2025-06-04 0:50 ` [PATCH AUTOSEL 6.15 070/118] tracing: Only return an adjusted address if it matches the kernel address Sasha Levin
2025-06-04 1:15 ` Steven Rostedt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250604005049.4147522-14-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=angelogioacchino.delregno@collabora.com \
--cc=krzysztof.kozlowski@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-bluetooth@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=luiz.dentz@gmail.com \
--cc=luiz.von.dentz@intel.com \
--cc=marcel@holtmann.org \
--cc=matthias.bgg@gmail.com \
--cc=patches@lists.linux.dev \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®