Skip to content

Commit c2994b0

Browse files
committed
Bluetooth: hci_sync: Fix not setting Random Address when required
This fixes errors such as the following when Own address type is set to Random Address but it has not been programmed yet due to either be advertising or connecting: < HCI Command: LE Set Exte.. (0x08|0x0041) plen 13 Own address type: Random (0x03) Filter policy: Ignore not in accept list (0x01) PHYs: 0x05 Entry 0: LE 1M Type: Passive (0x00) Interval: 60.000 msec (0x0060) Window: 30.000 msec (0x0030) Entry 1: LE Coded Type: Passive (0x00) Interval: 180.000 msec (0x0120) Window: 90.000 msec (0x0090) > HCI Event: Command Complete (0x0e) plen 4 LE Set Extended Scan Parameters (0x08|0x0041) ncmd 1 Status: Success (0x00) < HCI Command: LE Set Exten.. (0x08|0x0042) plen 6 Extended scan: Enabled (0x01) Filter duplicates: Enabled (0x01) Duration: 0 msec (0x0000) Period: 0.00 sec (0x0000) > HCI Event: Command Complete (0x0e) plen 4 LE Set Extended Scan Enable (0x08|0x0042) ncmd 1 Status: Invalid HCI Command Parameters (0x12) Fixes: c45074d ("Bluetooth: Fix not generating RPA when required") Signed-off-by: Luiz Augusto von Dentz <[email protected]>
1 parent db78475 commit c2994b0

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

net/bluetooth/hci_sync.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1031,18 +1031,19 @@ static bool adv_use_rpa(struct hci_dev *hdev, uint32_t flags)
10311031

10321032
static int hci_set_random_addr_sync(struct hci_dev *hdev, bdaddr_t *rpa)
10331033
{
1034-
/* If we're advertising or initiating an LE connection we can't
1035-
* go ahead and change the random address at this time. This is
1036-
* because the eventual initiator address used for the
1034+
/* If a random_addr has been set we're advertising or initiating an LE
1035+
* connection we can't go ahead and change the random address at this
1036+
* time. This is because the eventual initiator address used for the
10371037
* subsequently created connection will be undefined (some
10381038
* controllers use the new address and others the one we had
10391039
* when the operation started).
10401040
*
10411041
* In this kind of scenario skip the update and let the random
10421042
* address be updated at the next cycle.
10431043
*/
1044-
if (hci_dev_test_flag(hdev, HCI_LE_ADV) ||
1045-
hci_lookup_le_connect(hdev)) {
1044+
if (bacmp(&hdev->random_addr, BDADDR_ANY) &&
1045+
(hci_dev_test_flag(hdev, HCI_LE_ADV) ||
1046+
hci_lookup_le_connect(hdev))) {
10461047
bt_dev_dbg(hdev, "Deferring random address update");
10471048
hci_dev_set_flag(hdev, HCI_RPA_EXPIRED);
10481049
return 0;

0 commit comments

Comments
 (0)