Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Bluetooth: hci_core: Fix tracking of periodic advertisement

Periodic advertising enabled flag cannot be tracked by the enabled
flag since advertising and periodic advertising each can be
enabled/disabled separately from one another causing the states to be
inconsistent when for example an advertising set is disabled its
enabled flag is set to false which is then used for periodic which has
not being disabled.

Fixes: eca0ae4aea66 ("Bluetooth: Add initial implementation of BIS connections")
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

+8 -4
+1
include/net/bluetooth/hci_core.h
··· 244 244 bool enabled; 245 245 bool pending; 246 246 bool periodic; 247 + bool periodic_enabled; 247 248 __u8 mesh; 248 249 __u8 instance; 249 250 __u8 handle;
+5 -2
net/bluetooth/hci_event.c
··· 1607 1607 1608 1608 hci_dev_set_flag(hdev, HCI_LE_ADV); 1609 1609 1610 - if (adv && !adv->periodic) 1610 + if (adv) 1611 1611 adv->enabled = true; 1612 1612 else if (!set->handle) 1613 1613 hci_dev_set_flag(hdev, HCI_LE_ADV_0); ··· 3963 3963 hci_dev_set_flag(hdev, HCI_LE_PER_ADV); 3964 3964 3965 3965 if (adv) 3966 - adv->enabled = true; 3966 + adv->periodic_enabled = true; 3967 3967 } else { 3968 + if (adv) 3969 + adv->periodic_enabled = false; 3970 + 3968 3971 /* If just one instance was disabled check if there are 3969 3972 * any other instance enabled before clearing HCI_LE_PER_ADV. 3970 3973 * The current periodic adv instance will be marked as
+2 -2
net/bluetooth/hci_sync.c
··· 1607 1607 1608 1608 /* If periodic advertising already disabled there is nothing to do. */ 1609 1609 adv = hci_find_adv_instance(hdev, instance); 1610 - if (!adv || !adv->periodic || !adv->enabled) 1610 + if (!adv || !adv->periodic_enabled) 1611 1611 return 0; 1612 1612 1613 1613 memset(&cp, 0, sizeof(cp)); ··· 1672 1672 1673 1673 /* If periodic advertising already enabled there is nothing to do. */ 1674 1674 adv = hci_find_adv_instance(hdev, instance); 1675 - if (adv && adv->periodic && adv->enabled) 1675 + if (adv && adv->periodic_enabled) 1676 1676 return 0; 1677 1677 1678 1678 memset(&cp, 0, sizeof(cp));