diff mbox series

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

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

Checks

Context Check Description
tedd_an/pre-ci_am success Success
tedd_an/CheckPatch success CheckPatch PASS
tedd_an/GitLint success Gitlint PASS
tedd_an/BuildEll success Build ELL PASS
tedd_an/BluezMake success Bluez Make PASS
tedd_an/MakeCheck success Bluez Make Check PASS
tedd_an/MakeDistcheck success Make Distcheck PASS
tedd_an/CheckValgrind success Check Valgrind PASS
tedd_an/CheckSmatch success CheckSparse PASS
tedd_an/bluezmakeextell success Make External ELL PASS
tedd_an/IncrementalBuild success Incremental Build PASS
tedd_an/ScanBuild success Scan Build PASS

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(+)

Comments

bluez.test.bot@gmail.com June 27, 2024, 2:43 p.m. UTC | #1
This is automated email and please do not reply to this email!

Dear submitter,

Thank you for submitting the patches to the linux bluetooth mailing list.
This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=866157

---Test result---

Test Summary:
CheckPatch                    PASS      0.37 seconds
GitLint                       PASS      0.27 seconds
BuildEll                      PASS      24.58 seconds
BluezMake                     PASS      1730.99 seconds
MakeCheck                     PASS      13.51 seconds
MakeDistcheck                 PASS      177.37 seconds
CheckValgrind                 PASS      251.53 seconds
CheckSmatch                   PASS      353.45 seconds
bluezmakeextell               PASS      119.35 seconds
IncrementalBuild              PASS      1473.21 seconds
ScanBuild                     PASS      991.71 seconds



---
Regards,
Linux Bluetooth
patchwork-bot+bluetooth@kernel.org June 27, 2024, 6:40 p.m. UTC | #2
Hello:

This patch was applied to bluetooth/bluez.git (master)
by Luiz Augusto von Dentz <luiz.von.dentz@intel.com>:

On Thu, 27 Jun 2024 16:05:51 +0300 you wrote:
> 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.
> 
> [...]

Here is the summary with links:
  - [BlueZ,v1] media: fix memory leak in endpoint_init_pac()
    https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=bf4ec513929b

You are awesome, thank you!
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;
 	}