diff mbox series

[BlueZ,v1] media: fix memory leak in endpoint_init_pac()

Message ID 20240627130552.80610-1-r.smirnov@omp.ru
State New
Headers show
Series [BlueZ,v1] media: fix memory leak in endpoint_init_pac() | expand

Commit Message

Roman Smirnov June 27, 2024, 1:05 p.m. UTC
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 mbox series

Patch

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;
 	}