Skip to contentSkip to conversation

perf test x86: Fit memory leak in sample_ustack()

PATCH In review Masanari Iida 3 participants 5 messages Apr 19, 2014 – Apr 23, 2014 perf events

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 perf test x86: Fit memory leak in sample_ustack()

buf is not freed, when kernel failed to get stack map and return.

---
 tools/perf/arch/x86/tests/dwarf-unwind.c | 1 +
 1 file changed, 1 insertion(+)
tools/perf/arch/x86/tests/dwarf-unwind.c +1 -0
index b602ad9..68f2711 100644
@@ -26,6 +26,7 @@ static int sample_ustack(struct perf_sample *sample,
 	map = map_groups__find(&thread->mg, MAP__FUNCTION, (u64) sp);
 	if (!map) {
 		pr_debug("failed to get stack map\n");
+		kfree(buf);
 		return -1;
 	}
 
Signature · 1 line
1.9.2.468.g3f0c02a
Acked-by on v1 1/1
#1 lore raw
Quoted 4 lines · Masanari Iida

buf is not freed, when kernel failed to get stack map and return.

thanks,
jirka

Quoted 19 lines
---
 tools/perf/arch/x86/tests/dwarf-unwind.c | 1 +
 1 file changed, 1 insertion(+)
tools/perf/arch/x86/tests/dwarf-unwind.c +1 -0
index b602ad9..68f2711 100644
@@ -26,6 +26,7 @@ static int sample_ustack(struct perf_sample *sample,
 	map = map_groups__find(&thread->mg, MAP__FUNCTION, (u64) sp);
 	if (!map) {
 		pr_debug("failed to get stack map\n");
+		kfree(buf);
 		return -1;
 	}
 
Signature · 1 line
1.9.2.468.g3f0c02a
#2 lore raw
Quoted 15 lines · Jiri Olsa
Quoted 4 lines · Masanari Iida

buf is not freed, when kernel failed to get stack map and return.

thanks,
jirka

Quoted 4 lines
---
 tools/perf/arch/x86/tests/dwarf-unwind.c | 1 +
 1 file changed, 1 insertion(+)
Quoted 9 lines

tools/perf/arch/x86/tests/dwarf-unwind.c static int sample_ustack(struct perf_sample *sample, · line 29

Quoted 9 lines
tools/perf/arch/x86/tests/dwarf-unwind.c +1 -0
index b602ad9..68f2711 100644
@@ -26,6 +26,7 @@ static int sample_ustack(struct perf_sample *sample,
 	map = map_groups__find(&thread->mg, MAP__FUNCTION, (u64) sp);
 	if (!map) {
 		pr_debug("failed to get stack map\n");
+		kfree(buf);

and changing this to free(buf) ;-)

jirka

Quoted 6 lines
Quoted 6 lines
tools/perf/arch/x86/tests/dwarf-unwind.c +0 -0
 		return -1;
 	}
 
Signature · 1 line
1.9.2.468.g3f0c02a
#3 lore raw
In reply to Masanari Iida

buf is not freed, when program failed to get stack map

---
 tools/perf/arch/x86/tests/dwarf-unwind.c | 1 +
 1 file changed, 1 insertion(+)
tools/perf/arch/x86/tests/dwarf-unwind.c +1 -0
index b602ad9..b8c0102 100644
@@ -26,6 +26,7 @@ static int sample_ustack(struct perf_sample *sample,
 	map = map_groups__find(&thread->mg, MAP__FUNCTION, (u64) sp);
 	if (!map) {
 		pr_debug("failed to get stack map\n");
+		free(buf);
 		return -1;
 	}
 
Signature · 1 line
1.9.2.468.g3f0c02a
#4 lore raw

[tip:perf/urgent] perf tests x86: Fix memory leak in sample_ustack()

perf tests x86: Fix memory leak in sample_ustack()
Commit-ID:  763d7f5f2718f085bab5a9e63308349728f3ad12
Gitweb:     http://git.kernel.org/tip/763d7f5f2718f085bab5a9e63308349728f3ad12
Author:     Masanari Iida <[email protected]>
AuthorDate: Sun, 20 Apr 2014 00:16:41 +0900
Committer:  Jiri Olsa <[email protected]>
CommitDate: Wed, 23 Apr 2014 13:19:01 +0200

perf tests x86: Fix memory leak in sample_ustack()

The buf is not freed, when kernel failed to get stack map and return.

---
 tools/perf/arch/x86/tests/dwarf-unwind.c | 1 +
 1 file changed, 1 insertion(+)
tools/perf/arch/x86/tests/dwarf-unwind.c +1 -0
index b602ad9..b8c0102 100644
@@ -26,6 +26,7 @@ static int sample_ustack(struct perf_sample *sample,
 	map = map_groups__find(&thread->mg, MAP__FUNCTION, (u64) sp);
 	if (!map) {
 		pr_debug("failed to get stack map\n");
+		free(buf);
 		return -1;
 	}