diff mbox series

[BlueZ,v2,16/20] iso-tester: Fix fd leak

Message ID 20240510121355.3241456-17-hadess@hadess.net (mailing list archive)
State Accepted
Commit c81f9320357b0808dd4debebc687d26dc0be30ab
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 (83>80): "bluez-5.75/tools/iso-tester.c:1796:2: open_fn: Returning handle opened by "socket"." 5: B1 Line exceeds max length (111>80): "bluez-5.75/tools/iso-tester.c:1796:2: var_assign: Assigning: "sk" = handle returned from "socket(31, 2053, 8)"." 6: B1 Line exceeds max length (110>80): "bluez-5.75/tools/iso-tester.c:1807:3: leaked_handle: Handle variable "sk" going out of scope leaks the handle." 7: B3 Line contains hard tab characters (\t): "1805| if (!master_bdaddr) {" 8: B3 Line contains hard tab characters (\t): "1806| tester_warn("No master bdaddr");" 9: B3 Line contains hard tab characters (\t): "1807|-> return -ENODEV;" 10: B3 Line contains hard tab characters (\t): "1808| }"

Commit Message

Bastien Nocera May 10, 2024, 12:10 p.m. UTC
Error: RESOURCE_LEAK (CWE-772): [#def63] [important]
bluez-5.75/tools/iso-tester.c:1796:2: open_fn: Returning handle opened by "socket".
bluez-5.75/tools/iso-tester.c:1796:2: var_assign: Assigning: "sk" = handle returned from "socket(31, 2053, 8)".
bluez-5.75/tools/iso-tester.c:1807:3: leaked_handle: Handle variable "sk" going out of scope leaks the handle.
1805|		if (!master_bdaddr) {
1806|			tester_warn("No master bdaddr");
1807|->			return -ENODEV;
1808|		}
1809|
---
 tools/iso-tester.c | 1 +
 1 file changed, 1 insertion(+)
diff mbox series

Patch

diff --git a/tools/iso-tester.c b/tools/iso-tester.c
index 046606068206..d54fa56ecd44 100644
--- a/tools/iso-tester.c
+++ b/tools/iso-tester.c
@@ -1804,6 +1804,7 @@  static int create_iso_sock(struct test_data *data)
 	master_bdaddr = hciemu_get_central_bdaddr(data->hciemu);
 	if (!master_bdaddr) {
 		tester_warn("No master bdaddr");
+		close(sk);
 		return -ENODEV;
 	}