summaryrefslogtreecommitdiff
path: root/mesh
diff options
context:
space:
mode:
authorInga Stotland <inga.stotland@gmail.com>2023-03-09 17:35:12 -0800
committerBrian Gix <brian.gix@gmail.com>2023-03-12 11:57:54 -0700
commit40576ac1badffb151ada76a90b89e85aa2ed9934 (patch)
treeeefb65650531252dfeed16836f756c597e2ce0d2 /mesh
parent815f779aa8e477e399b78f03c0ea0e75f0270c4a (diff)
downloadbluez-40576ac1badffb151ada76a90b89e85aa2ed9934.tar.gz
mesh: Fix node when loading from storage
This fixes adding mandatory models (config server, remote provisioner) to a node whose configuration is being loaded from storage: mesh_model_add() was called with a wrong argument. Was: mesh_model_add(..., PRIMARY_ELE_IDX, ...); Correct: mesh_model_add(..., ele->models, ...);
Diffstat (limited to 'mesh')
-rw-r--r--mesh/node.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/mesh/node.c b/mesh/node.c
index ed3212685..93537c5ba 100644
--- a/mesh/node.c
+++ b/mesh/node.c
@@ -347,6 +347,7 @@ static bool add_elements_from_storage(struct mesh_node *node,
struct mesh_config_node *db_node)
{
const struct l_queue_entry *entry;
+ struct node_element *ele;
entry = l_queue_get_entries(db_node->elements);
@@ -354,14 +355,19 @@ static bool add_elements_from_storage(struct mesh_node *node,
if (!add_element_from_storage(node, entry->data))
return false;
+ ele = l_queue_find(node->elements, match_element_idx,
+ L_UINT_TO_PTR(PRIMARY_ELE_IDX));
+ if (!ele)
+ return false;
+
/* Add configuration server model on the primary element */
- mesh_model_add(node, PRIMARY_ELE_IDX, CONFIG_SRV_MODEL, NULL);
+ mesh_model_add(node, ele->models, CONFIG_SRV_MODEL, NULL);
/* Add remote provisioning models on the primary element */
- mesh_model_add(node, PRIMARY_ELE_IDX, REM_PROV_SRV_MODEL, NULL);
+ mesh_model_add(node, ele->models, REM_PROV_SRV_MODEL, NULL);
if (node->provisioner)
- mesh_model_add(node, PRIMARY_ELE_IDX, REM_PROV_CLI_MODEL, NULL);
+ mesh_model_add(node, ele->models, REM_PROV_CLI_MODEL, NULL);
return true;
}