diff mbox series

[Bluez,03/13] Fixing memroy leak in jlink.c

Message ID 20220530081209.560465-4-gopalkrishna.tiwari@gmail.com (mailing list archive)
State Superseded
Headers show
Series Fixing memory leak, leaked_handle and use_after | expand

Checks

Context Check Description
tedd_an/pre-ci_am success Success
tedd_an/checkpatch warning [Bluez,03/13] Fixing memroy leak in jlink.c WARNING:TYPO_SPELLING: 'memroy' may be misspelled - perhaps 'memory'? #45: Subject: [Bluez 03/13] Fixing memroy leak in jlink.c ^^^^^^ WARNING:COMMIT_LOG_LONG_LINE: Possible unwrapped commit description (prefer a maximum 75 chars per line) #58: While performing static tool analysis using coverity found following reports for resouse leak /github/workspace/src/12864388.patch total: 0 errors, 2 warnings, 13 lines checked NOTE: For some of the reported defects, checkpatch may be able to mechanically convert to the typical style using --fix or --fix-inplace. /github/workspace/src/12864388.patch has style problems, please review. NOTE: Ignored message types: COMMIT_MESSAGE COMPLEX_MACRO CONST_STRUCT FILE_PATH_CHANGES MISSING_SIGN_OFF PREFER_PACKED SPDX_LICENSE_TAG SPLIT_STRING SSCANF_TO_KSTRTO NOTE: If any of the errors are false positives, please report them to the maintainer, see CHECKPATCH in MAINTAINERS.
tedd_an/gitlint fail [Bluez,03/13] Fixing memroy leak in jlink.c 5: B1 Line exceeds max length (93>80): "While performing static tool analysis using coverity found following reports for resouse leak" 7: B1 Line exceeds max length (112>80): "bluez-5.64/monitor/jlink.c:111: leaked_storage: Variable "so" going out of scope leaks the storage it points to." 9: B1 Line exceeds max length (112>80): "bluez-5.64/monitor/jlink.c:113: leaked_storage: Variable "so" going out of scope leaks the storage it points to."

Commit Message

Gopal Tiwari May 30, 2022, 8:11 a.m. UTC
From: Gopal Tiwari <gtiwari@redhat.com>

While performing static tool analysis using coverity found following reports for resouse leak

bluez-5.64/monitor/jlink.c:111: leaked_storage: Variable "so" going out of scope leaks the storage it points to.

bluez-5.64/monitor/jlink.c:113: leaked_storage: Variable "so" going out of scope leaks the storage it points to.

Fixing them.

Signed-off-by: Gopal Tiwari <gtiwari@redhat.com>
---
 monitor/jlink.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/monitor/jlink.c b/monitor/jlink.c
index 9aaa4ebd8..672097004 100644
--- a/monitor/jlink.c
+++ b/monitor/jlink.c
@@ -107,9 +107,12 @@  int jlink_init(void)
 			!jlink.tif_select || !jlink.setspeed ||
 			!jlink.connect || !jlink.getsn ||
 			!jlink.emu_getproductname ||
-			!jlink.rtterminal_control || !jlink.rtterminal_read)
+			!jlink.rtterminal_control || !jlink.rtterminal_read) {
+		dlclose(so);
 		return -EIO;
+	}
 
+	dlclose(so)
 	return 0;
 }