All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] perf: tests: fix some mmemory leak issues
@ 2021-07-02  4:09 ` gushengxian
  0 siblings, 0 replies; 8+ messages in thread
From: gushengxian @ 2021-07-02  4:09 UTC (permalink / raw)
  To: will, mathieu.poirier, leo.yan, peterz, mingo, acme, mark.rutland,
	alexander.shishkin, jolsa, namhyung, linux-arm-kernel
  Cc: linux-perf-users, linux-kernel, gushengxian

From: gushengxian <gushengxian@yulong.com>

Some memory leak issues should be fixed by free().
Reported by cppcheck.

Signed-off-by: gushengxian <gushengxian@yulong.com>
---
 tools/perf/arch/arm/tests/dwarf-unwind.c     | 1 +
 tools/perf/arch/arm64/tests/dwarf-unwind.c   | 1 +
 tools/perf/arch/powerpc/tests/dwarf-unwind.c | 1 +
 tools/perf/arch/x86/tests/dwarf-unwind.c     | 1 +
 4 files changed, 4 insertions(+)

diff --git a/tools/perf/arch/arm/tests/dwarf-unwind.c b/tools/perf/arch/arm/tests/dwarf-unwind.c
index ccfa87055c4a..f2541d1dbb02 100644
--- a/tools/perf/arch/arm/tests/dwarf-unwind.c
+++ b/tools/perf/arch/arm/tests/dwarf-unwind.c
@@ -39,6 +39,7 @@ static int sample_ustack(struct perf_sample *sample,
 	memcpy(buf, (void *) sp, stack_size);
 	stack->data = (char *) buf;
 	stack->size = stack_size;
+	free(buf);
 	return 0;
 }
 
diff --git a/tools/perf/arch/arm64/tests/dwarf-unwind.c b/tools/perf/arch/arm64/tests/dwarf-unwind.c
index 46147a483049..ecd25c77a71f 100644
--- a/tools/perf/arch/arm64/tests/dwarf-unwind.c
+++ b/tools/perf/arch/arm64/tests/dwarf-unwind.c
@@ -39,6 +39,7 @@ static int sample_ustack(struct perf_sample *sample,
 	memcpy(buf, (void *) sp, stack_size);
 	stack->data = (char *) buf;
 	stack->size = stack_size;
+	free(buf);
 	return 0;
 }
 
diff --git a/tools/perf/arch/powerpc/tests/dwarf-unwind.c b/tools/perf/arch/powerpc/tests/dwarf-unwind.c
index 8efd9ed9e9db..e57a8ca52ce7 100644
--- a/tools/perf/arch/powerpc/tests/dwarf-unwind.c
+++ b/tools/perf/arch/powerpc/tests/dwarf-unwind.c
@@ -40,6 +40,7 @@ static int sample_ustack(struct perf_sample *sample,
 	memcpy(buf, (void *) sp, stack_size);
 	stack->data = (char *) buf;
 	stack->size = stack_size;
+	free(buf);
 	return 0;
 }
 
diff --git a/tools/perf/arch/x86/tests/dwarf-unwind.c b/tools/perf/arch/x86/tests/dwarf-unwind.c
index 478078fb0f22..da90b33a1e28 100644
--- a/tools/perf/arch/x86/tests/dwarf-unwind.c
+++ b/tools/perf/arch/x86/tests/dwarf-unwind.c
@@ -47,6 +47,7 @@ static int sample_ustack(struct perf_sample *sample,
 #endif
 	stack->data = (char *) buf;
 	stack->size = stack_size;
+	free(buf);
 	return 0;
 }
 
-- 
2.25.1


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

end of thread, other threads:[~2021-07-02 17:59 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-07-02  4:09 [PATCH] perf: tests: fix some mmemory leak issues gushengxian
2021-07-02  4:09 ` gushengxian
2021-07-02 12:58 ` Arnaldo Carvalho de Melo
2021-07-02 12:58   ` Arnaldo Carvalho de Melo
2021-07-02 13:56   ` Leo Yan
2021-07-02 13:56     ` Leo Yan
2021-07-02 17:57     ` Arnaldo Carvalho de Melo
2021-07-02 17:57       ` Arnaldo Carvalho de Melo

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.