From a4a1f0383e9611706c2f7884557bf1b99e5ab1e3 Mon Sep 17 00:00:00 2001 From: Inga Stotland Date: Wed, 3 Jul 2019 13:53:41 -0700 Subject: [PATCH] mesh: Fix checks when restoring internal model state This fixes incorrect conditional checks in restore_model_state() which could lead to dereferencing a NULL pointer. Change-Id: I65631b3cd22c9e5f5e43aa62e093c227182749b8 Wrong: if (l_queue_isempty(mod->bindings) || !mod->cbs->bind) ... Fixed: if (!l_queue_isempty(mod->bindings) && cbs->bind) ... Signed-off-by: Anupam Roy --- mesh/model.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mesh/model.c b/mesh/model.c index a2b3e5c..e4a7ba9 100644 --- a/mesh/model.c +++ b/mesh/model.c @@ -1077,7 +1077,7 @@ static void restore_model_state(struct mesh_model *mod) if (!cbs) return; - if (l_queue_isempty(mod->bindings) || !mod->cbs->bind) { + if (!l_queue_isempty(mod->bindings) && cbs->bind) { for (b = l_queue_get_entries(mod->bindings); b; b = b->next) { if (cbs->bind(L_PTR_TO_UINT(b->data), ACTION_ADD) != MESH_STATUS_SUCCESS) -- 2.7.4