From: Hang Nan <2122295973@qq.com>
To: linux-bluetooth@vger.kernel.org
Cc: marcel@holtmann.org, luiz.dentz@gmail.com,
luiz.von.dentz@intel.com, pav@iki.fi, zzzccc427@gmail.com,
enderaoelyther@gmail.com
Subject: [PATCH v3] Bluetooth: RFCOMM: hold the listener across child teardown
Date: Fri, 20 Nov 2026 20:18:26 +0800 [thread overview]
Message-ID: <tencent_5C090D89F54B3F9DA10CEFA2CA9E8AD8EC05@qq.com> (raw)
In-Reply-To: <20261115191908.3646-enderaoelyther@gmail.com>
---
net/bluetooth/rfcomm/sock.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/net/bluetooth/rfcomm/sock.c b/net/bluetooth/rfcomm/sock.c
index 3fb8b5474948..94a495e86057 100644
--- a/net/bluetooth/rfcomm/sock.c
+++ b/net/bluetooth/rfcomm/sock.c
@@ -66,6 +66,7 @@ static void rfcomm_sk_state_change(struct rfcomm_dlc *d, int err)
__must_hold(&d->lock)
{
struct sock *sk = d->owner, *parent;
+ bool held = false;
if (!sk)
return;
@@ -83,6 +84,12 @@ static void rfcomm_sk_state_change(struct rfcomm_dlc *d, int err)
if (parent) {
if (d->state == BT_CLOSED) {
sock_set_flag(sk, SOCK_ZAPPED);
+ /* close() may already have dropped its reference and the
+ * queue holds none, so keep the listener alive across the
+ * unlink and the notification.
+ */
+ sock_hold(parent);
+ held = true;
bt_accept_unlink(sk);
}
parent->sk_data_ready(parent);
@@ -100,6 +107,12 @@ static void rfcomm_sk_state_change(struct rfcomm_dlc *d, int err)
* rfcomm_sock_destruct() will dead lock. */
rfcomm_dlc_unlock(d);
rfcomm_sock_kill(sk);
+ /* Drop the listener reference with neither the child's socket
+ * lock nor its DLC lock held: this put can be the final one and
+ * rfcomm_sock_destruct() takes the listener's own DLC mutex.
+ */
+ if (held)
+ sock_put(parent);
rfcomm_dlc_lock(d);
}
}
--
2.47.3
parent reply other threads:[~2026-11-20 12:18 UTC|newest]
Thread overview: expand[flat|nested] mbox.gz Atom feed
[parent not found: <20261115191908.3646-enderaoelyther@gmail.com>]
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=tencent_5C090D89F54B3F9DA10CEFA2CA9E8AD8EC05@qq.com \
--to=2122295973@qq.com \
--cc=enderaoelyther@gmail.com \
--cc=linux-bluetooth@vger.kernel.org \
--cc=luiz.dentz@gmail.com \
--cc=luiz.von.dentz@intel.com \
--cc=marcel@holtmann.org \
--cc=pav@iki.fi \
--cc=zzzccc427@gmail.com \
/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