Linux bluetooth development
 help / color / mirror / Atom feed
* [PATCH] Bluetooth: L2CAP: fix chan ref leak in l2cap_chan_timeout() on !conn
@ 2026-05-21  2:30 Siwei Zhang
  2026-05-21  4:27 ` bluez.test.bot
  2026-05-21 15:30 ` [PATCH] " patchwork-bot+bluetooth
  0 siblings, 2 replies; 3+ messages in thread
From: Siwei Zhang @ 2026-05-21  2:30 UTC (permalink / raw)
  To: Marcel Holtmann, Luiz Augusto von Dentz; +Cc: linux-bluetooth, Siwei Zhang

__set_chan_timer() takes a l2cap_chan reference via l2cap_chan_hold()
before scheduling the delayed work.  The normal path in
l2cap_chan_timeout() drops this reference with l2cap_chan_put() at the
end, but the early return when chan->conn is NULL skips the put,
leaking the reference.

Add the missing l2cap_chan_put() before the early return.

Fixes: adf0398cee86 ("Bluetooth: l2cap: fix null-ptr-deref in l2cap_chan_timeout")
Cc: stable@vger.kernel.org
Signed-off-by: Siwei Zhang <oss@fourdim.xyz>
---
 net/bluetooth/l2cap_core.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index fdccd62ccca8..5668c92b3f58 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -411,8 +411,10 @@ static void l2cap_chan_timeout(struct work_struct *work)
 
 	BT_DBG("chan %p state %s", chan, state_to_string(chan->state));
 
-	if (!conn)
+	if (!conn) {
+		l2cap_chan_put(chan);
 		return;
+	}
 
 	mutex_lock(&conn->lock);
 	/* __set_chan_timer() calls l2cap_chan_hold(chan) while scheduling
-- 
2.54.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* RE: Bluetooth: L2CAP: fix chan ref leak in l2cap_chan_timeout() on !conn
  2026-05-21  2:30 [PATCH] Bluetooth: L2CAP: fix chan ref leak in l2cap_chan_timeout() on !conn Siwei Zhang
@ 2026-05-21  4:27 ` bluez.test.bot
  2026-05-21 15:30 ` [PATCH] " patchwork-bot+bluetooth
  1 sibling, 0 replies; 3+ messages in thread
From: bluez.test.bot @ 2026-05-21  4:27 UTC (permalink / raw)
  To: linux-bluetooth, oss

[-- Attachment #1: Type: text/plain, Size: 937 bytes --]

This is automated email and please do not reply to this email!

Dear submitter,

Thank you for submitting the patches to the linux bluetooth mailing list.
This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=1098397

---Test result---

Test Summary:
CheckPatch                    PASS      0.74 seconds
GitLint                       PASS      0.34 seconds
SubjectPrefix                 PASS      0.13 seconds
BuildKernel                   PASS      25.59 seconds
CheckAllWarning               PASS      27.76 seconds
CheckSparse                   PASS      26.46 seconds
BuildKernel32                 PASS      24.69 seconds
TestRunnerSetup               PASS      530.44 seconds
TestRunner_l2cap-tester       PASS      374.90 seconds
IncrementalBuild              PASS      24.34 seconds



https://github.com/bluez/bluetooth-next/pull/226

---
Regards,
Linux Bluetooth


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Bluetooth: L2CAP: fix chan ref leak in l2cap_chan_timeout() on !conn
  2026-05-21  2:30 [PATCH] Bluetooth: L2CAP: fix chan ref leak in l2cap_chan_timeout() on !conn Siwei Zhang
  2026-05-21  4:27 ` bluez.test.bot
@ 2026-05-21 15:30 ` patchwork-bot+bluetooth
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+bluetooth @ 2026-05-21 15:30 UTC (permalink / raw)
  To: Siwei Zhang; +Cc: marcel, luiz.dentz, linux-bluetooth

Hello:

This patch was applied to bluetooth/bluetooth-next.git (master)
by Luiz Augusto von Dentz <luiz.von.dentz@intel.com>:

On Wed, 20 May 2026 22:30:36 -0400 you wrote:
> __set_chan_timer() takes a l2cap_chan reference via l2cap_chan_hold()
> before scheduling the delayed work.  The normal path in
> l2cap_chan_timeout() drops this reference with l2cap_chan_put() at the
> end, but the early return when chan->conn is NULL skips the put,
> leaking the reference.
> 
> Add the missing l2cap_chan_put() before the early return.
> 
> [...]

Here is the summary with links:
  - Bluetooth: L2CAP: fix chan ref leak in l2cap_chan_timeout() on !conn
    https://git.kernel.org/bluetooth/bluetooth-next/c/628669434306

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-05-21 15:30 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-21  2:30 [PATCH] Bluetooth: L2CAP: fix chan ref leak in l2cap_chan_timeout() on !conn Siwei Zhang
2026-05-21  4:27 ` bluez.test.bot
2026-05-21 15:30 ` [PATCH] " patchwork-bot+bluetooth

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox