From 063991424c778642be4b0a4149e0e2933df05f58 Mon Sep 17 00:00:00 2001 From: Olivier Lesage Date: Mon, 26 Aug 2024 11:30:30 +0200 Subject: [PATCH] bluetooth: host: Ignore HCI err 0xC when setting own addr when initiating Ignores "command disallowed" if the host privacy implementation tries to change the device's random address while scanning or initiating. This is not allowed by spec. It's caused by scan_update() in scan.c. Signed-off-by: Olivier Lesage --- subsys/bluetooth/host/id.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/subsys/bluetooth/host/id.c b/subsys/bluetooth/host/id.c index 871e016f581..6261e1fabb7 100644 --- a/subsys/bluetooth/host/id.c +++ b/subsys/bluetooth/host/id.c @@ -1786,7 +1786,12 @@ int bt_id_set_scan_own_addr(bool active_scan, uint8_t *own_addr_type) if (IS_ENABLED(CONFIG_BT_PRIVACY)) { err = bt_id_set_private_addr(BT_ID_DEFAULT); - if (err) { + if (err == -EACCES && (atomic_test_bit(bt_dev.flags, BT_DEV_SCANNING) || + atomic_test_bit(bt_dev.flags, BT_DEV_INITIATING))) { + LOG_WRN("Set random addr failure ignored in scan/init state"); + + return 0; + } else if (err) { return err; }