All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] perf kmem: Fix memory leak in compact_gfp_flags()
@ 2019-10-16  8:38 Yunfeng Ye
  2019-10-16 13:04 ` Arnaldo Carvalho de Melo
  2019-10-21  6:26 ` [tip: perf/urgent] " tip-bot2 for Yunfeng Ye
  0 siblings, 2 replies; 7+ messages in thread
From: Yunfeng Ye @ 2019-10-16  8:38 UTC (permalink / raw)
  To: peterz, mingo, acme, mark.rutland, alexander.shishkin, jolsa, namhyung
  Cc: linux-kernel, hushiyuan, linfeilong

The memory @orig_flags is allocated by strdup(), it is freed on the
normal path, but leak to free on the error path.

Fix this by adding free(orig_flags) on the error path.

Signed-off-by: Yunfeng Ye <yeyunfeng@huawei.com>
---
 tools/perf/builtin-kmem.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tools/perf/builtin-kmem.c b/tools/perf/builtin-kmem.c
index 1e61e353f579..9661671cc26e 100644
--- a/tools/perf/builtin-kmem.c
+++ b/tools/perf/builtin-kmem.c
@@ -691,6 +691,7 @@ static char *compact_gfp_flags(char *gfp_flags)
 			new = realloc(new_flags, len + strlen(cpt) + 2);
 			if (new == NULL) {
 				free(new_flags);
+				free(orig_flags);
 				return NULL;
 			}

-- 
2.7.4.3


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2019-10-21  6:27 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-16  8:38 [PATCH] perf kmem: Fix memory leak in compact_gfp_flags() Yunfeng Ye
2019-10-16 13:04 ` Arnaldo Carvalho de Melo
2019-10-16 13:09   ` Arnaldo Carvalho de Melo
2019-10-16 13:19     ` Yunfeng Ye
2019-10-16 14:08       ` Arnaldo Carvalho de Melo
2019-10-16 14:17         ` Yunfeng Ye
2019-10-21  6:26 ` [tip: perf/urgent] " tip-bot2 for Yunfeng Ye

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.