Skip to content

Commit 6de5b79

Browse files
Johan Hedbergjhedberg
authored andcommitted
Bluetooth: Mesh: Fix discarding messages with many segments
The code for checking space in the Friend queue was faulty in the case that we receive a message with more segments than the configured Friend Queue size. This is not an issue for the default configuration but still a possible one. Move the check for exceeding Friend Queue Size to the per-LPN function, so that bt_mesh_friend_queue_has_space() iterates all LPNs before delivering its verdict. This allows us to return success in case no LPN matched (which is how the code was intended to work). Fixes #18522 Signed-off-by: Johan Hedberg <[email protected]>
1 parent aded6a5 commit 6de5b79

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

subsys/bluetooth/mesh/friend.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1226,6 +1226,10 @@ static bool friend_queue_has_space(struct bt_mesh_friend *frnd, u16_t addr,
12261226
u32_t total = 0;
12271227
int i;
12281228

1229+
if (seg_count > CONFIG_BT_MESH_FRIEND_QUEUE_SIZE) {
1230+
return false;
1231+
}
1232+
12291233
for (i = 0; i < ARRAY_SIZE(frnd->seg); i++) {
12301234
struct bt_mesh_friend_seg *seg = &frnd->seg[i];
12311235

@@ -1259,10 +1263,6 @@ bool bt_mesh_friend_queue_has_space(u16_t net_idx, u16_t src, u16_t dst,
12591263
bool someone_has_space = false, friend_match = false;
12601264
int i;
12611265

1262-
if (seg_count > CONFIG_BT_MESH_FRIEND_QUEUE_SIZE) {
1263-
return false;
1264-
}
1265-
12661266
for (i = 0; i < ARRAY_SIZE(bt_mesh.frnd); i++) {
12671267
struct bt_mesh_friend *frnd = &bt_mesh.frnd[i];
12681268

0 commit comments

Comments
 (0)