Skip to content

Commit aba318a

Browse files
committed
Bluetooth: CSIP: Fix off-by-one in in lock restore
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 <[email protected]>
1 parent 8232440 commit aba318a

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

subsys/bluetooth/audio/csip_set_coordinator.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1113,7 +1113,7 @@ static void csip_set_coordinator_write_lock_cb(struct bt_conn *conn,
11131113

11141114
active.members_restored = 0;
11151115

1116-
member = active.members[active.members_handled - active.members_restored];
1116+
member = active.members[active.members_handled - 1];
11171117
client->cur_inst = lookup_instance_by_set_info(member, &active.info);
11181118
if (client->cur_inst == NULL) {
11191119
LOG_DBG("Failed to lookup instance by set_info");
@@ -1130,10 +1130,10 @@ static void csip_set_coordinator_write_lock_cb(struct bt_conn *conn,
11301130
active_members_reset();
11311131
return;
11321132
}
1133+
} else {
1134+
lock_set_complete(err);
11331135
}
11341136

1135-
lock_set_complete(err);
1136-
11371137
return;
11381138
}
11391139

0 commit comments

Comments
 (0)