All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] orangefs: fix memory leak of string 'new' on exit path
@ 2016-12-02 15:18 Colin King
  0 siblings, 0 replies; only message in thread
From: Colin King @ 2016-12-02 15:18 UTC (permalink / raw)
  To: Mike Marshall; +Cc: linux-kernel

From: Colin Ian King <colin.king@canonical.com>

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"

Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 fs/orangefs/orangefs-debugfs.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/fs/orangefs/orangefs-debugfs.c b/fs/orangefs/orangefs-debugfs.c
index 38887cc..b5dbc9c 100644
--- a/fs/orangefs/orangefs-debugfs.c
+++ b/fs/orangefs/orangefs-debugfs.c
@@ -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);
-- 
2.10.2

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2016-12-02 15:18 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-12-02 15:18 [PATCH] orangefs: fix memory leak of string 'new' on exit path Colin King

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.