Skip to content

Commit 3636767

Browse files
theob-pronashif
authored andcommitted
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 <[email protected]>
1 parent 09085ef commit 3636767

File tree

1 file changed

+2
-3
lines changed
  • subsys/bluetooth/host

1 file changed

+2
-3
lines changed

subsys/bluetooth/host/id.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1273,12 +1273,11 @@ int bt_id_create(bt_addr_le_t *addr, uint8_t *irk)
12731273
}
12741274
}
12751275

1276-
new_id = bt_dev.id_count;
1276+
new_id = bt_dev.id_count++;
12771277
err = id_create(new_id, addr, irk);
12781278
if (err) {
1279+
bt_dev.id_count--;
12791280
return err;
1280-
} else {
1281-
bt_dev.id_count++;
12821281
}
12831282

12841283
return new_id;

0 commit comments

Comments
 (0)