Bluetooth: Host: Fix wrong ID being stored
Fix an issue causing a wrong Bluetooth identity value to be stored. It was happening because the `bt_dev.id_count` was incremented after the settings being stored. To fix this, `bt_dev.id_count` is now incremented right before the ID creation and is decremented if the ID creation failed. Signed-off-by: Théo Battrel <theo.battrel@nordicsemi.no>
This commit is contained in:
parent
09085ef63c
commit
363676764a
|
@ -1273,12 +1273,11 @@ int bt_id_create(bt_addr_le_t *addr, uint8_t *irk)
|
|||
}
|
||||
}
|
||||
|
||||
new_id = bt_dev.id_count;
|
||||
new_id = bt_dev.id_count++;
|
||||
err = id_create(new_id, addr, irk);
|
||||
if (err) {
|
||||
bt_dev.id_count--;
|
||||
return err;
|
||||
} else {
|
||||
bt_dev.id_count++;
|
||||
}
|
||||
|
||||
return new_id;
|
||||
|
|
Loading…
Reference in a new issue