Skip to content

Commit

Permalink
Bluetooth: CSIP: Fix off-by-one in in lock restore
Browse files Browse the repository at this point in the history
If the lock request was rejected by a set member we should
restore any previously written logs in reverse order.

However there was a off-by-one error in
csip_set_coordinator_write_lock_cb which caused us to attempt to
release member[1] instead of member[0] if member[1] was the
one that rejected the lock request.

Additionally, the lock_set_complete would be called
prematurely before we get the response from the restore
request.

Signed-off-by: Emil Gydesen <emil.gydesen@nordicsemi.no>
  • Loading branch information
Thalley authored and mmahadevan108 committed Nov 8, 2024
1 parent 5776436 commit 7c40b07
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions subsys/bluetooth/audio/csip_set_coordinator.c
Original file line number Diff line number Diff line change
Expand Up @@ -1113,7 +1113,7 @@ static void csip_set_coordinator_write_lock_cb(struct bt_conn *conn,

active.members_restored = 0;

member = active.members[active.members_handled - active.members_restored];
member = active.members[active.members_handled - 1];
client->cur_inst = lookup_instance_by_set_info(member, &active.info);
if (client->cur_inst == NULL) {
LOG_DBG("Failed to lookup instance by set_info");
Expand All @@ -1130,10 +1130,10 @@ static void csip_set_coordinator_write_lock_cb(struct bt_conn *conn,
active_members_reset();
return;
}
} else {
lock_set_complete(err);
}

lock_set_complete(err);

return;
}

Expand Down

0 comments on commit 7c40b07

Please sign in to comment.