Skip to contentSkip to conversation

orangefs: fix memory leak of string 'new' on exit path

PATCH New Colin King 1 participant 1 message Dec 2, 2016 Orangefs filesystem

lore
Share & tools
lore

Colin King

author
#0 lore raw

PATCH 1/1 orangefs: fix memory leak of string 'new' on exit path

From: Colin Ian King <[email protected]>

allocates string 'new' is not free'd on the exit path when cdm_element_count <= 0. Fix this by kfree'ing it.

Fixes CoverityScan CID#1375923 "Resource Leak"

---
 fs/orangefs/orangefs-debugfs.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
fs/orangefs/orangefs-debugfs.c +3 -1
index 38887cc..b5dbc9c 100644
@@ -671,8 +671,10 @@ int orangefs_prepare_debugfs_help_string(int at_boot)
 		 */
 		cdm_element_count =
 			orangefs_prepare_cdm_array(client_debug_array_string);
-		if (cdm_element_count <= 0)
+		if (cdm_element_count <= 0) {
+			kfree(new);
 			goto out;
+		}
 
 		for (i = 0; i < cdm_element_count; i++) {
 			strlcat(new, "\t", string_size);
Signature · 1 line
2.10.2