Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[nrf fromtree] Bluetooth: Host: Fix issue where uninitialized value w… #2109

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions subsys/bluetooth/host/id.c
Original file line number Diff line number Diff line change
Expand Up @@ -1785,6 +1785,13 @@ int bt_id_set_scan_own_addr(bool active_scan, uint8_t *own_addr_type)
}

if (IS_ENABLED(CONFIG_BT_PRIVACY)) {

if (BT_FEAT_LE_PRIVACY(bt_dev.le.features)) {
*own_addr_type = BT_HCI_OWN_ADDR_RPA_OR_RANDOM;
} else {
*own_addr_type = BT_ADDR_LE_RANDOM;
}

err = bt_id_set_private_addr(BT_ID_DEFAULT);
if (err == -EACCES && (atomic_test_bit(bt_dev.flags, BT_DEV_SCANNING) ||
atomic_test_bit(bt_dev.flags, BT_DEV_INITIATING))) {
Expand All @@ -1794,12 +1801,6 @@ int bt_id_set_scan_own_addr(bool active_scan, uint8_t *own_addr_type)
} else if (err) {
return err;
}

if (BT_FEAT_LE_PRIVACY(bt_dev.le.features)) {
*own_addr_type = BT_HCI_OWN_ADDR_RPA_OR_RANDOM;
} else {
*own_addr_type = BT_ADDR_LE_RANDOM;
}
} else {
*own_addr_type = bt_dev.id_addr[0].type;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ ZTEST(bt_id_set_scan_own_addr_invalid_inputs, test_set_random_address_fails)
* Expected behaviour:
* - bt_id_set_scan_own_addr() fails and returns the same error code returned by
* bt_id_set_private_addr()
* - Address type reference isn't set
*/
ZTEST(bt_id_set_scan_own_addr_invalid_inputs, test_bt_id_set_private_addr_fails_privacy_enabled)
{
Expand All @@ -131,6 +130,4 @@ ZTEST(bt_id_set_scan_own_addr_invalid_inputs, test_bt_id_set_private_addr_fails_
#endif

zassert_true(err < 0, "Unexpected error code '%d' was returned", err);
zassert_true(own_addr_type == BT_ADDR_LE_ANONYMOUS,
"Address type reference was unexpectedly modified");
}
Loading