From 6617c2970493e05dbb921bc20c7d9a3fe08b5c52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krzysztof=20Kopy=C5=9Bci=C5=84ski?= Date: Fri, 22 Oct 2021 08:12:43 +0200 Subject: [PATCH] host/mesh: Model extensions walk stops before last model When reaching the last model in the circular extension linked list, the walker would abandon the walk before checking the last model. This makes us skip models when checking the subscription list, potentially causing incoming messages to be wrongfully ignored. This is port of cd89f4239368b106fbfab9555cf445fbc00203a2 --- nimble/host/mesh/src/access.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/nimble/host/mesh/src/access.c b/nimble/host/mesh/src/access.c index 33169a750..6df342afe 100644 --- a/nimble/host/mesh/src/access.c +++ b/nimble/host/mesh/src/access.c @@ -819,11 +819,11 @@ void bt_mesh_model_extensions_walk(struct bt_mesh_model *model, #else struct bt_mesh_model *it; - if (model->next == NULL) { - (void)cb(model, user_data); + if (cb(model, user_data) == BT_MESH_WALK_STOP || !model->next) { return; } - for (it = model; (it != NULL) && (it->next != model); it = it->next) { + /* List is circular. Step through all models until we reach the start: */ + for (it = model->next; it != model; it = it->next) { if (cb(it, user_data) == BT_MESH_WALK_STOP) { return; }