public inbox for linux-bluetooth@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH BlueZ v1] health/mcap: fix memory leak in mcap_create_mcl()
@ 2024-06-27 13:32 Roman Smirnov
  2024-06-27 15:37 ` [BlueZ,v1] " bluez.test.bot
  2024-06-27 18:40 ` [PATCH BlueZ v1] " patchwork-bot+bluetooth
  0 siblings, 2 replies; 3+ messages in thread
From: Roman Smirnov @ 2024-06-27 13:32 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Roman Smirnov

set_default_cb() can allocate memory for mcl->cb but it does
not free mcl->cb before exiting the function.

Add freeing mcl->cb before exiting the function.

Found by Linux Verification Center (linuxtesting.org) with the SVACE
static analysis tool.
---
 profiles/health/mcap.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/profiles/health/mcap.c b/profiles/health/mcap.c
index 5d2bac3d9..b544b9a0a 100644
--- a/profiles/health/mcap.c
+++ b/profiles/health/mcap.c
@@ -1907,6 +1907,7 @@ gboolean mcap_create_mcl(struct mcap_instance *mi,
 		set_default_cb(mcl);
 		if (util_getrandom(&val, sizeof(val), 0) < 0) {
 			mcap_instance_unref(mcl->mi);
+			g_free(mcl->cb);
 			g_free(mcl);
 			return FALSE;
 		}
-- 
2.43.0


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

end of thread, other threads:[~2024-06-27 18:40 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-27 13:32 [PATCH BlueZ v1] health/mcap: fix memory leak in mcap_create_mcl() Roman Smirnov
2024-06-27 15:37 ` [BlueZ,v1] " bluez.test.bot
2024-06-27 18:40 ` [PATCH BlueZ v1] " patchwork-bot+bluetooth

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox