Skip to content

Commit 0d5640e

Browse files
Johan Hedbergnashif
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 configure 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 ce83a7c commit 0d5640e

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

subsys/bluetooth/host/mesh/friend.c

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

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

@@ -1258,10 +1262,6 @@ bool bt_mesh_friend_queue_has_space(u16_t net_idx, u16_t src, u16_t dst,
12581262
bool someone_has_space = false, friend_match = false;
12591263
int i;
12601264

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

0 commit comments

Comments
 (0)