diff mbox series

[Bluez,08/13] Fixing resource leak in mesh/mesh-db.c

Message ID 20220530081209.560465-9-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,08/13] Fixing resource leak in mesh/mesh-db.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/12864393.patch total: 0 errors, 1 warnings, 8 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/12864393.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,08/13] Fixing resource leak in mesh/mesh-db.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 (110>80): "bluez-5.64/tools/mesh/mesh-db.c:2388: leaked_handle: Handle variable "fd" going out of scope leaks the handle." 9: B1 Line exceeds max length (119>80): "bluez-5.64/tools/mesh/mesh-db.c:2388: leaked_storage: Variable "str" going out of scope leaks the storage it points to."

Commit Message

Gopal Tiwari May 30, 2022, 8:12 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/tools/mesh/mesh-db.c:2388: leaked_handle: Handle variable "fd" going out of scope leaks the handle.

bluez-5.64/tools/mesh/mesh-db.c:2388: leaked_storage: Variable "str" going out of scope leaks the storage it points to.

Signed-off-by: Gopal Tiwari <gtiwari@redhat.com>
---
 tools/mesh/mesh-db.c | 2 ++
 1 file changed, 2 insertions(+)
diff mbox series

Patch

diff --git a/tools/mesh/mesh-db.c b/tools/mesh/mesh-db.c
index fa11837df..896ff722c 100644
--- a/tools/mesh/mesh-db.c
+++ b/tools/mesh/mesh-db.c
@@ -2384,6 +2384,8 @@  bool mesh_db_load(const char *fname)
 
 	sz = read(fd, str, st.st_size);
 	if (sz != st.st_size) {
+		close(fd);
+		l_free(str);
 		l_error("Failed to read configuration file %s", fname);
 		return false;
 	}