From 29a67338d12a298baeb85c68a53d255e1ddf2fa3 Mon Sep 17 00:00:00 2001 From: Kamil Piszczek Date: Thu, 26 Oct 2023 13:24:13 +0200 Subject: [PATCH] bluetooth: id: fix uninitialized RPA for non-default identities This change fixes uninitialized RPA values for advertising sets of non-default Bluetooth identities. The regression has been introduced in the following commit: https://github.com/zephyrproject-rtos/zephyr/commit/8d6b206064c915316245616a718ae29eb157a717 The follow-up fix for the default Bluetooth identity has been introduced in a separate commit: https://github.com/zephyrproject-rtos/zephyr/commit/88c20b9cddf0bd5e5d6c163611b2563f9266be6f Non-default Bluetooth identities can be loaded from the Settings subsystem. In this case, RPAs of related advertising sets to these identities are left uninitialized as the bt_id_create() function context is not executed. As a result, the RPA is not created for advertising sets of non-default Bluetooth identities, and the advertising is started with the 00:00:00:00:00:00 address. Signed-off-by: Kamil Piszczek --- subsys/bluetooth/host/id.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/subsys/bluetooth/host/id.c b/subsys/bluetooth/host/id.c index 4bbc5e23192..cf07418dd02 100644 --- a/subsys/bluetooth/host/id.c +++ b/subsys/bluetooth/host/id.c @@ -2064,7 +2064,9 @@ int bt_id_init(void) int err; #if defined(CONFIG_BT_PRIVACY) - bt_addr_copy(&bt_dev.rpa[BT_ID_DEFAULT], BT_ADDR_NONE); + for (uint8_t id = 0U; id < ARRAY_SIZE(bt_dev.rpa); id++) { + bt_addr_copy(&bt_dev.rpa[id], BT_ADDR_NONE); + } k_work_init_delayable(&bt_dev.rpa_update, rpa_timeout); #endif