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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 --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);
-- 
2.43.0





[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux