summaryrefslogtreecommitdiff
path: root/mesh
diff options
context:
space:
mode:
authorInga Stotland <inga.stotland@intel.com>2020-11-09 20:24:51 -0800
committerBrian Gix <brian.gix@intel.com>2020-11-10 10:24:11 -0800
commitffdaeed4171ab90271ff111d47471b7874a81f81 (patch)
tree8496b285e9fa18c8d84ee71d02e4f35d1c7d99c1 /mesh
parent1896700957e42919e283168e68598ff41b829c8c (diff)
downloadbluez-ffdaeed4171ab90271ff111d47471b7874a81f81.tar.gz
mesh: Fix memory leak when failing to load a node
This fixes a memory leak that may occur on unsuccessful element initialization from storage.
Diffstat (limited to 'mesh')
-rw-r--r--mesh/node.c7
1 files changed, 2 insertions, 5 deletions
diff --git a/mesh/node.c b/mesh/node.c
index 11b0c9442..35293e0f0 100644
--- a/mesh/node.c
+++ b/mesh/node.c
@@ -326,16 +326,13 @@ static bool add_element_from_storage(struct mesh_node *node,
ele->idx = db_ele->index;
ele->location = db_ele->location;
-
-
- if (!ele->models)
- ele->models = l_queue_new();
+ ele->models = l_queue_new();
+ l_queue_push_tail(node->elements, ele);
if (!mesh_model_add_from_storage(node, ele->idx, ele->models,
db_ele->models))
return false;
- l_queue_push_tail(node->elements, ele);
return true;
}