Skip to contentSkip to conversation

mesh: Fix memory leak when failing to load a node

PATCH Applied Inga Stotland 3 participants 3 messages Nov 10, 2020 Bluetooth drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mesh: Fix memory leak when failing to load a node

This fixes a memory leak that may occur on unsuccessful element initialization from storage.

---
 mesh/node.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
mesh/node.c +2 -5
index 11b0c9442..35293e0f0 100644
@@ -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;
 }
 
Signature · 1 line
2.26.2
#1 lore raw

This is automated email and please do not reply to this email!

Dear submitter,

Thank you for submitting the patches to the linux bluetooth mailing list. This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=380863

---Test result---

##############################
Test: CheckPatch - PASS

##############################
Test: CheckGitLint - PASS

##############################
Test: CheckBuild - PASS

##############################
Test: MakeCheck - PASS

---
Regards,
Linux Bluetooth

Applied
#2 lore raw
In reply to Inga Stotland

Applied

Quoted 29 lines · Inga Stotland

This fixes a memory leak that may occur on unsuccessful element initialization from storage.

---
 mesh/node.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
mesh/node.c +2 -5
index 11b0c9442..35293e0f0 100644
@@ -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;
 }