diff mbox series

[Bluez,v2,4/4] shared/mgmt: Fix memory leak in mgmt_tlv_list

Message ID 20201228180429.Bluez.v2.4.I43884adadc00a5095dd03d2261a71dc2ba80d986@changeid (mailing list archive)
State New, archived
Headers show
Series [Bluez,v2,1/4] shared/mgmt: Add supports of parsing mgmt tlv list | expand

Commit Message

Howard Chung Dec. 28, 2020, 10:04 a.m. UTC
This patch freed the mgmt_tlv properly in mgmt_tlv_list_free.

Reviewed-by: apusaka@chromium.org
Reviewed-by: mcchou@chromium.org
---

Changes in v2:
- Fix incompatible pointer type error of mgmt_tlv_free

 src/shared/mgmt.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/src/shared/mgmt.c b/src/shared/mgmt.c
index dc8107846668..0d0c957709d7 100644
--- a/src/shared/mgmt.c
+++ b/src/shared/mgmt.c
@@ -588,14 +588,15 @@  static struct mgmt_tlv *mgmt_tlv_new(uint16_t type, uint8_t length,
 	return entry;
 }
 
-static void mgmt_tlv_free(struct mgmt_tlv *entry)
+static void mgmt_tlv_free(void *data)
 {
+	struct mgmt_tlv *entry = data;
 	free(entry);
 }
 
 void mgmt_tlv_list_free(struct mgmt_tlv_list *tlv_list)
 {
-	queue_destroy(tlv_list->tlv_queue, NULL);
+	queue_destroy(tlv_list->tlv_queue, mgmt_tlv_free);
 	free(tlv_list);
 }