diff mbox series

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

Message ID 20240510121355.3241456-17-hadess@hadess.net
State New
Headers show
Series Fix a number of static analysis issues | expand

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