Linux bluetooth development
 help / color / mirror / Atom feed
From: Simon Mikuda <simon.mikuda@streamunlimited.com>
To: linux-bluetooth@vger.kernel.org
Cc: Simon Mikuda <simon.mikuda@streamunlimited.com>,
	Marcel Holtmann <marcel@holtmann.org>,
	Luiz Augusto von Dentz <luiz.dentz@gmail.com>
Subject: [PATCH] Bluetooth: hci_event: Terminate a PA sync nobody accepts
Date: Tue, 24 Nov 2026 16:08:51 +0100	[thread overview]
Message-ID: <20261124150851.338673-1-simon.mikuda@streamunlimited.com> (raw)

The accept mask of hci_le_pa_sync_established_evt() starts from
hdev->link_mode, which has HCI_LM_ACCEPT set by default, so a PA sync no
ISO socket accepted is never terminated. This happens when the listening
socket closes while the sync is pending. Every later sync to that source
then fails until it stops advertising:

    < LE Periodic Advertising Create Sync  50:1E:2D:A1:5F:1C
      (listening socket closed)
    > LE Periodic Advertising Sync Established  Status: Success
      (no LE Periodic Advertising Terminate Sync)
    < LE Periodic Advertising Create Sync  50:1E:2D:A1:5F:1C
    > Command Status  ACL Connection Already Exists (0x0b)

Only ISO can accept a PA sync, so start from 0 and let
hci_proto_connect_ind() decide. Terminate only an established sync. A
failed sync has no handle, so the handle in its event means nothing and
can be the handle of another sync. The NXP IW612 Bluetooth chip, for
example, reports a cancelled create with handle 0.

Fixes: eca0ae4aea66 ("Bluetooth: Add initial implementation of BIS connections")
Signed-off-by: Simon Mikuda <simon.mikuda@streamunlimited.com>
---
 net/bluetooth/hci_event.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
index 610207e25fa4..2da77ebee12d 100644
--- a/net/bluetooth/hci_event.c
+++ b/net/bluetooth/hci_event.c
@@ -6814,7 +6814,7 @@ static void hci_le_pa_sync_established_evt(struct hci_dev *hdev, void *data,
 					   struct sk_buff *skb)
 {
 	struct hci_ev_le_pa_sync_established *ev = data;
-	int mask = hdev->link_mode;
+	int mask = 0;
 	__u8 flags = 0;
 	struct hci_conn *pa_sync, *conn;
 
@@ -6848,7 +6848,11 @@ static void hci_le_pa_sync_established_evt(struct hci_dev *hdev, void *data,
 	mask |= hci_proto_connect_ind(hdev, &ev->bdaddr, PA_LINK,
 				      &flags);
 	if (!(mask & HCI_LM_ACCEPT)) {
-		hci_le_pa_term_sync(hdev, ev->handle);
+		/* A failed sync has no handle, the one in the event may be
+		 * another sync's.
+		 */
+		if (!ev->status)
+			hci_le_pa_term_sync(hdev, ev->handle);
 		goto unlock;
 	}
 

base-commit: 62fd917f6d2df1a399a453138c2b7cbd563f8f95
-- 
2.43.0


             reply	other threads:[~2026-11-24 15:08 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-24 15:08 Simon Mikuda [this message]
2026-11-24 17:20 ` [PATCH] Bluetooth: hci_event: Terminate a PA sync nobody accepts patchwork-bot+bluetooth

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=20261124150851.338673-1-simon.mikuda@streamunlimited.com \
    --to=simon.mikuda@streamunlimited.com \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=luiz.dentz@gmail.com \
    --cc=marcel@holtmann.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