summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Gix <brian.gix@intel.com>2020-05-15 18:22:03 -0700
committerAbhay Agarwal <ay.agarwal@samsung.com>2020-05-22 09:53:44 +0530
commit50878c77f02c64adc1374501c5bb8901e79fe3b6 (patch)
tree58f8e7bc22aaf961c6b493d0c62e30396d1d7f45
parent5ffa23ee564f86d647446cf45e4c8d2150e97d40 (diff)
downloadbluez-50878c77f02c64adc1374501c5bb8901e79fe3b6.tar.gz
bluez-50878c77f02c64adc1374501c5bb8901e79fe3b6.tar.bz2
bluez-50878c77f02c64adc1374501c5bb8901e79fe3b6.zip
mesh: Fix valgrind memory leak warnings
These warnings are caused by not completely freeing memory allocations at shutdown, and are not serious, but they make valgrind output cleaner. Change-Id: Ib08bb727fee9ea6dccd5e484bcd5d2f969b80a19 Signed-off-by: Abhay Agarwal <ay.agarwal@samsung.com>
-rw-r--r--mesh/agent.c1
-rw-r--r--mesh/mesh.c4
-rw-r--r--mesh/net-keys.c6
-rw-r--r--mesh/net-keys.h1
-rw-r--r--mesh/net.c12
-rw-r--r--mesh/net.h3
6 files changed, 25 insertions, 2 deletions
diff --git a/mesh/agent.c b/mesh/agent.c
index bb52f414..a06cc2b9 100644
--- a/mesh/agent.c
+++ b/mesh/agent.c
@@ -245,6 +245,7 @@ void mesh_agent_cleanup(void)
return;
l_queue_destroy(agents, agent_free);
+ agents = NULL;
}
diff --git a/mesh/mesh.c b/mesh/mesh.c
index 6cacacac..133a0c90 100644
--- a/mesh/mesh.c
+++ b/mesh/mesh.c
@@ -26,6 +26,7 @@
#include "mesh/mesh-io.h"
#include "mesh/node.h"
#include "mesh/net.h"
+#include "mesh/net-keys.h"
#include "mesh/provision.h"
#include "mesh/model.h"
#include "mesh/dbus.h"
@@ -339,8 +340,11 @@ void mesh_cleanup(void)
}
l_queue_destroy(pending_queue, pending_request_exit);
+ mesh_agent_cleanup();
node_cleanup_all();
mesh_model_cleanup();
+ mesh_net_cleanup();
+ net_key_cleanup();
l_dbus_object_remove_interface(dbus_get_bus(), BLUEZ_MESH_PATH,
MESH_NETWORK_INTERFACE);
diff --git a/mesh/net-keys.c b/mesh/net-keys.c
index f7eb2ca6..7dfabf92 100644
--- a/mesh/net-keys.c
+++ b/mesh/net-keys.c
@@ -523,3 +523,9 @@ void net_key_beacon_disable(uint32_t id)
l_timeout_remove(key->snb.timeout);
key->snb.timeout = NULL;
}
+
+void net_key_cleanup(void)
+{
+ l_queue_destroy(keys, l_free);
+ keys = NULL;
+}
diff --git a/mesh/net-keys.h b/mesh/net-keys.h
index 9385e2c5..4f480fcd 100644
--- a/mesh/net-keys.h
+++ b/mesh/net-keys.h
@@ -21,6 +21,7 @@
#define KEY_REFRESH 0x01
#define IV_INDEX_UPDATE 0x02
+void net_key_cleanup(void);
bool net_key_confirm(uint32_t id, const uint8_t master[16]);
bool net_key_retrieve(uint32_t id, uint8_t *master);
uint32_t net_key_add(const uint8_t master[16]);
diff --git a/mesh/net.c b/mesh/net.c
index bd36e2d4..dcba34f8 100644
--- a/mesh/net.c
+++ b/mesh/net.c
@@ -679,8 +679,10 @@ struct mesh_net *mesh_net_new(struct mesh_node *node)
return net;
}
-void mesh_net_free(struct mesh_net *net)
+void mesh_net_free(void *user_data)
{
+ struct mesh_net *net = user_data;
+
if (!net)
return;
@@ -699,6 +701,14 @@ void mesh_net_free(struct mesh_net *net)
l_free(net);
}
+void mesh_net_cleanup(void)
+{
+ l_queue_destroy(fast_cache, l_free);
+ fast_cache = NULL;
+ l_queue_destroy(nets, mesh_net_free);
+ nets = NULL;
+}
+
bool mesh_net_set_seq_num(struct mesh_net *net, uint32_t seq)
{
if (!net)
diff --git a/mesh/net.h b/mesh/net.h
index bfc8064f..8646d5ae 100644
--- a/mesh/net.h
+++ b/mesh/net.h
@@ -265,7 +265,8 @@ typedef void (*mesh_net_status_func_t)(uint16_t remote, uint8_t status,
void *user_data);
struct mesh_net *mesh_net_new(struct mesh_node *node);
-void mesh_net_free(struct mesh_net *net);
+void mesh_net_free(void *net);
+void mesh_net_cleanup(void);
void mesh_net_flush_msg_queues(struct mesh_net *net);
void mesh_net_set_iv_index(struct mesh_net *net, uint32_t index, bool update);
bool mesh_net_iv_index_update(struct mesh_net *net);