diff mbox series

[BlueZ,02/10] mesh: Free allocated agent in mesh_remove_agent()

Message ID 20200522003501.106165-3-inga.stotland@intel.com
State New
Headers show
Series Mesh code clean up | expand

Commit Message

Inga Stotland May 22, 2020, 12:34 a.m. UTC
This adds previously missing call to free memory allocated
for agent structure.
---
 mesh/agent.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)
diff mbox series

Patch

diff --git a/mesh/agent.c b/mesh/agent.c
index a06cc2b99..4d200416f 100644
--- a/mesh/agent.c
+++ b/mesh/agent.c
@@ -188,9 +188,6 @@  static void agent_free(void *agent_data)
 	mesh_agent_key_cb_t key_cb;
 	mesh_agent_number_cb_t number_cb;
 
-	if (!l_queue_find(agents, simple_match, agent))
-		return;
-
 	err = MESH_ERROR_DOES_NOT_EXIST;
 
 	if (agent->req && agent->req->cb) {
@@ -228,15 +225,16 @@  static void agent_free(void *agent_data)
 
 	l_free(agent->path);
 	l_free(agent->owner);
+	l_free(agent);
 }
 
 void mesh_agent_remove(struct mesh_agent *agent)
 {
-	if (!agent || !l_queue_find(agents, simple_match, agent))
+	if (!agent)
 		return;
 
-	agent_free(agent);
-	l_queue_remove(agents, agent);
+	if (l_queue_remove(agents, agent))
+		agent_free(agent);
 }
 
 void mesh_agent_cleanup(void)