From: Jeremy Dean Clifton <deaner92@yahoo.com>
To: marcel@holtmann.org, luiz.dentz@gmail.com
Cc: linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org,
william.xuanziyang@huawei.com, johan.hedberg@intel.com,
hdanton@sina.com, Jeremy Dean Clifton <deaner92@yahoo.com>
Subject: [PATCH v2 1/3] Bluetooth: hci_conn: Free the unset handle when adding a connection fails
Date: Tue, 17 Nov 2026 02:33:42 +0000 [thread overview]
Message-ID: <20261117023344.278269-2-deaner92@yahoo.com> (raw)
In-Reply-To: <20261117023344.278269-1-deaner92@yahoo.com>
hci_conn_add_unset() reserves a handle from hdev->unset_handle_ida and
passes it to __hci_conn_add(). When __hci_conn_add() returns an error,
no hci_conn exists, so hci_conn_cleanup() never runs and the handle is
never returned to the IDA. It stays reserved until the device is
released.
The Sashiko AI reviewer found this while reviewing a change
that adds another error return to __hci_conn_add().
Free the handle in hci_conn_add_unset() when __hci_conn_add() fails.
Fixes: 181a42edddf5 ("Bluetooth: Make handle of hci_conn be unique")
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Jeremy Dean Clifton <deaner92@yahoo.com>
---
net/bluetooth/hci_conn.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c
index c474263fbab9..d729a72f2f77 100644
--- a/net/bluetooth/hci_conn.c
+++ b/net/bluetooth/hci_conn.c
@@ -1176,6 +1176,7 @@ static struct hci_conn *__hci_conn_add(struct hci_dev *hdev, int type,
struct hci_conn *hci_conn_add_unset(struct hci_dev *hdev, int type,
bdaddr_t *dst, u8 dst_type, u8 role)
{
+ struct hci_conn *conn;
int handle;
bt_dev_dbg(hdev, "dst %pMR", dst);
@@ -1184,7 +1185,11 @@ struct hci_conn *hci_conn_add_unset(struct hci_dev *hdev, int type,
if (unlikely(handle < 0))
return ERR_PTR(-ECONNREFUSED);
- return __hci_conn_add(hdev, type, dst, dst_type, role, handle);
+ conn = __hci_conn_add(hdev, type, dst, dst_type, role, handle);
+ if (IS_ERR(conn))
+ ida_free(&hdev->unset_handle_ida, handle);
+
+ return conn;
}
struct hci_conn *hci_conn_add(struct hci_dev *hdev, int type, bdaddr_t *dst,
--
2.43.0
next prev parent reply other threads:[~2026-11-17 2:35 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20261117023344.278269-1-deaner92.ref@yahoo.com>
2026-11-17 2:33 ` [PATCH v2 0/3] Bluetooth: Fix work queued while hci_dev_close_sync() drains Jeremy Dean Clifton
2026-11-17 2:33 ` Jeremy Dean Clifton [this message]
2026-11-17 2:33 ` [PATCH v2 2/3] Bluetooth: hci_conn: Refuse new connections once HCI_UP is cleared Jeremy Dean Clifton
2026-11-17 2:33 ` [PATCH v2 3/3] Bluetooth: hci_sync: Disable connection works before draining Jeremy Dean Clifton
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=20261117023344.278269-2-deaner92@yahoo.com \
--to=deaner92@yahoo.com \
--cc=hdanton@sina.com \
--cc=johan.hedberg@intel.com \
--cc=linux-bluetooth@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=luiz.dentz@gmail.com \
--cc=marcel@holtmann.org \
--cc=william.xuanziyang@huawei.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
all inboxes | Powered by JetHome®