[prev in list] [next in list] [prev in thread] [next in thread] 

List:       linux-bluetooth
Subject:    [BlueZ v2 15/20] isotest: Fix fd leak
From:       Bastien Nocera <hadess () hadess ! net>
Date:       2024-05-10 12:10:25
Message-ID: 20240510121355.3241456-16-hadess () hadess ! net
[Download RAW message or body]

Error: RESOURCE_LEAK (CWE-772): [#def65] [important]
bluez-5.75/tools/isotest.c:923:4: open_fn: Returning handle opened by "open_file".
bluez-5.75/tools/isotest.c:923:4: var_assign: Assigning: "fd" = handle returned from \
"open_file(altername)". bluez-5.75/tools/isotest.c:953:3: leaked_handle: Handle \
variable "fd" going out of scope leaks the handle. 951|
952|		free(sk_arr);
953|->		return;
954|	}
955|
---
 tools/isotest.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/tools/isotest.c b/tools/isotest.c
index ddace0da3044..58293133a304 100644
--- a/tools/isotest.c
+++ b/tools/isotest.c
@@ -950,6 +950,8 @@ static void send_mode(char *filename, char *peer, int i, bool \
repeat)  close(sk_arr[i]);
 
 		free(sk_arr);
+		if (fd >= 0)
+			close(fd);
 		return;
 	}
 
-- 
2.44.0


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic