public inbox for linux-bluetooth@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH BlueZ v1] media: fix memory leak in endpoint_init_pac()
@ 2024-06-27 13:05 Roman Smirnov
  2024-06-27 14:43 ` [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:05 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Roman Smirnov

asprintf() allocates memory in the name variable but does not
free it before exiting the function, which causes a memory leak.

Add freeing of the name variable before exiting.

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

diff --git a/profiles/audio/media.c b/profiles/audio/media.c
index b5644736a..746e538fc 100644
--- a/profiles/audio/media.c
+++ b/profiles/audio/media.c
@@ -1280,6 +1280,7 @@ static bool endpoint_init_pac(struct media_endpoint *endpoint, uint8_t type,
 	if (asprintf(&name, "%s:%s", endpoint->sender, endpoint->path) < 0) {
 		error("Could not allocate name for pac %s:%s",
 				endpoint->sender, endpoint->path);
+		free(name);
 		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:05 [PATCH BlueZ v1] media: fix memory leak in endpoint_init_pac() Roman Smirnov
2024-06-27 14:43 ` [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