diff mbox series

[BlueZ,v2,15/20] isotest: Fix fd leak

Message ID 20240510121355.3241456-16-hadess@hadess.net (mailing list archive)
State Accepted
Commit 3e03788ba80c94888d9e78bf1c8f62fff42353b8
Headers show
Series Fix a number of static analysis issues | expand

Checks

Context Check Description
tedd_an/pre-ci_am success Success
tedd_an/CheckPatch success CheckPatch PASS
tedd_an/GitLint fail WARNING: I3 - ignore-body-lines: gitlint will be switching from using Python regex 'match' (match beginning) to 'search' (match anywhere) semantics. Please review your ignore-body-lines.regex option accordingly. To remove this warning, set general.regex-style-search=True. More details: https://jorisroovers.github.io/gitlint/configuration/#regex-style-search 4: B1 Line exceeds max length (82>80): "bluez-5.75/tools/isotest.c:923:4: open_fn: Returning handle opened by "open_file"." 5: B1 Line exceeds max length (108>80): "bluez-5.75/tools/isotest.c:923:4: var_assign: Assigning: "fd" = handle returned from "open_file(altername)"." 6: B1 Line exceeds max length (106>80): "bluez-5.75/tools/isotest.c:953:3: leaked_handle: Handle variable "fd" going out of scope leaks the handle." 8: B3 Line contains hard tab characters (\t): "952| free(sk_arr);" 9: B3 Line contains hard tab characters (\t): "953|-> return;" 10: B3 Line contains hard tab characters (\t): "954| }"

Commit Message

Bastien Nocera May 10, 2024, 12:10 p.m. UTC
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 mbox series

Patch

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