All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH BlueZ] emulator: Free hooks in btdev_destroy
@ 2026-10-10  3:18 Iaroslav Voitovych
  2026-10-10  9:42 ` [BlueZ] " bluez.test.bot
  2026-10-12 21:50 ` [PATCH BlueZ] " patchwork-bot+bluetooth
  0 siblings, 2 replies; 3+ messages in thread
From: Iaroslav Voitovych @ 2026-10-10  3:18 UTC (permalink / raw)
  To: linux-bluetooth

Hooks added with btdev_add_hook() are only freed by btdev_del_hook(),
so a hook still installed when the device is destroyed is leaked. Five
mgmt-tester cases leave one installed: "Add + Remove Device Nowait -
Success" and the four "Adv. (non-)connectable & connected" cases on the
LE emulator; one l2cap-tester case does too. They pass, but with ASan
the tester exits with status 1 because LeakSanitizer reports, for
mgmt-tester:

  Direct leak of 120 byte(s) in 5 object(s) allocated from:
    #0 in malloc
    #1 in btdev_add_hook emulator/btdev.c:8891

Free the remaining hooks in btdev_destroy().

Fixes: 37199df506f4 ("emulator: Add support for pre/post command/event hooks")
---
 emulator/btdev.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/emulator/btdev.c b/emulator/btdev.c
index e00f78288..ecc24a72b 100644
--- a/emulator/btdev.c
+++ b/emulator/btdev.c
@@ -8424,6 +8424,8 @@ struct btdev *btdev_create(enum btdev_type type, uint16_t id)
 
 void btdev_destroy(struct btdev *btdev)
 {
+	int i;
+
 	if (!btdev)
 		return;
 
@@ -8438,6 +8440,9 @@ void btdev_destroy(struct btdev *btdev)
 	queue_destroy(btdev->le_per_adv, free);
 	queue_destroy(btdev->le_big, le_big_free);
 
+	for (i = 0; i < MAX_HOOK_ENTRIES; i++)
+		free(btdev->hook_list[i]);
+
 	free(btdev);
 }
 

base-commit: 7428ca2df9356363079db0f48412c20cbdb9471f
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-10-12 21:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-10  3:18 [PATCH BlueZ] emulator: Free hooks in btdev_destroy Iaroslav Voitovych
2026-10-10  9:42 ` [BlueZ] " bluez.test.bot
2026-10-12 21:50 ` [PATCH BlueZ] " patchwork-bot+bluetooth

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.