* [PATCH v3] Bluetooth: hci_sync: Don't enable instance 0 on Set Connectable
@ 2026-11-23 9:25 Simon Mikuda
2026-11-23 12:06 ` [v3] " bluez.test.bot
0 siblings, 1 reply; 2+ messages in thread
From: Simon Mikuda @ 2026-11-23 9:25 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Simon Mikuda, Marcel Holtmann, Luiz Augusto von Dentz
hci_update_connectable_sync() restarts the advertising of
hdev->cur_adv_instance whenever the Advertising setting is on or an
advertising instance exists. cur_adv_instance can be 0 while instances
exist, for example after the current instance was removed while another
one keeps advertising. On a controller with extended advertising, Set
Connectable then sets up and enables advertising set 0x00, the set of
the Advertising setting, although that setting is off.
Steps to reproduce, after a boot, on a controller with extended
advertising:
btmgmt advertising off
btmgmt connectable off
btmgmt add-adv -d 06097465737431 1
btmgmt add-adv -d 06097465737432 2
btmgmt rm-adv 2
btmgmt connectable on
btmon of the last step:
@ MGMT Command: Set Connectable (0x0007) plen 1
Connectable: Enabled (0x01)
[...]
< HCI Command: LE Set Extended Advertising Parameters (0x08|0x0036)
Handle: 0x00
Properties: 0x0013
Connectable
Scannable
Use legacy advertising PDUs: ADV_IND
[...]
< HCI Command: LE Set Extended Advertising Enable (0x08|0x0039) plen 6
Extended advertising: Enabled (0x01)
Number of sets: 1 (0x01)
Entry 0
Handle: 0x00
Duration: 0 ms (0x00)
Max ext adv events: 0
> HCI Event: Command Complete (0x0e) plen 4
LE Set Extended Advertising Enable (0x08|0x0039) ncmd 1
Status: Success (0x00)
To fix this we will also check that cur_adv_instance is not 0, because
that indicates that no added instance is the current one: instance 0
is the one of the Advertising setting, and with that setting off there
is nothing to restart.
Fixes: de181e887ac2 ("Bluetooth: Impmlement extended adv enable")
Signed-off-by: Simon Mikuda <simon.mikuda@streamunlimited.com>
---
Changes in v3:
- The !list_empty(&hdev->adv_instances) check is kept next to the new
one. v2 dropped it: with cur_adv_instance naming an instance removed
during a peripheral connection, Set Connectable then failed with
Invalid Parameters on an extended advertising controller and enabled
advertising on a legacy one.
- Commit message: steps and trace are from a run on hardware
(RPi5 with Intel BE200), on a kernel built from bluetooth-next (7.3-rc2)
plus patches of ours that are not upstream. I test it against other devices
StreamKits (Synaptics, Realtek, NXP controllers - but kernel is not latest)
- Missing in the v2 changelog: v1 failed six mgmt-tester cases in CI,
the "Add (Ext) Advertising - Success ... (Connectable -> on/off)" ones.
v2: https://lore.kernel.org/linux-bluetooth/20261122191904.2261177-1-simon.mikuda@streamunlimited.com/
v1: https://lore.kernel.org/linux-bluetooth/20261122145428.1499940-1-simon.mikuda@streamunlimited.com/
net/bluetooth/hci_sync.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/bluetooth/hci_sync.c b/net/bluetooth/hci_sync.c
index 638589f77081..9896917c973b 100644
--- a/net/bluetooth/hci_sync.c
+++ b/net/bluetooth/hci_sync.c
@@ -6649,7 +6649,7 @@ int hci_update_connectable_sync(struct hci_dev *hdev)
/* Update the advertising parameters if necessary */
if (hci_dev_test_flag(hdev, HCI_ADVERTISING) ||
- !list_empty(&hdev->adv_instances)) {
+ (!list_empty(&hdev->adv_instances) && hdev->cur_adv_instance)) {
if (ext_adv_capable(hdev))
err = hci_start_ext_adv_sync(hdev,
hdev->cur_adv_instance);
base-commit: 4fe38719e6738feaa90486e36b0790dd5d960a96
--
2.43.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-23 12:07 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-23 9:25 [PATCH v3] Bluetooth: hci_sync: Don't enable instance 0 on Set Connectable Simon Mikuda
2026-11-23 12:06 ` [v3] " bluez.test.bot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox