diff mbox series

[BlueZ,v1,3/3] android/avdtp: fix leak in avdtp_new()

Message ID 20240809162252.50098-4-r.smirnov@omp.ru (mailing list archive)
State Accepted
Commit 537e399aa0960d57de5ba958ed4ddde713cd7ae2
Headers show
Series fix errors found by SVACE static analyzer #4 | 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/IncrementalBuild success Incremental Build PASS

Commit Message

Roman Smirnov Aug. 9, 2024, 4:22 p.m. UTC
It is necessary to close the file descriptor in case of an error.

Found with the SVACE static analysis tool.
---
 android/avdtp.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/android/avdtp.c b/android/avdtp.c
index a261a8e5f..e0466853b 100644
--- a/android/avdtp.c
+++ b/android/avdtp.c
@@ -2130,8 +2130,10 @@  struct avdtp *avdtp_new(int fd, size_t imtu, size_t omtu, uint16_t version,
 		return NULL;
 	}
 
-	if (set_priority(new_fd, 6) < 0)
+	if (set_priority(new_fd, 6) < 0) {
+		close(new_fd);
 		return NULL;
+	}
 
 	session = g_new0(struct avdtp, 1);
 	session->io = g_io_channel_unix_new(new_fd);