linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH perf/core ] [BUGFIX] perf probe: Fix a segfault when removing uprobe events
@ 2015-09-16 12:52 Masami Hiramatsu
  2015-09-18  1:39 ` 平松雅巳 / HIRAMATU,MASAMI
  2015-09-18 21:24 ` Paul Clarke
  0 siblings, 2 replies; 6+ messages in thread
From: Masami Hiramatsu @ 2015-09-16 12:52 UTC (permalink / raw)
  To: Namhyung Kim, Arnaldo Carvalho de Melo
  Cc: linux-perf-users, linux-kernel, Milian Wolff

Fix a segfault bug and a small mistake in perf probe -d.

Since the "ulist" in perf_del_probe_events is never initialized,
strlist__add(ulist, *) always causes a segfault when removing
uprobe events by perf probe -d.

Also, the "str" local variable is never released if fail to
allocate the "klist". This fixes it too.

This has been introduced by the commit e607f1426b58 ("perf probe:
Print deleted events in cmd_probe()").

Reported-by: Milian Wolff <milian.wolff@kdab.com>
Signed-off-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
---
 tools/perf/builtin-probe.c |    7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/tools/perf/builtin-probe.c b/tools/perf/builtin-probe.c
index 94385ee..f7882ae 100644
--- a/tools/perf/builtin-probe.c
+++ b/tools/perf/builtin-probe.c
@@ -380,8 +380,11 @@ static int perf_del_probe_events(struct strfilter *filter)
 		goto out;
 
 	klist = strlist__new(NULL, NULL);
-	if (!klist)
-		return -ENOMEM;
+	ulist = strlist__new(NULL, NULL);
+	if (!klist || !ulist) {
+		ret = -ENOMEM;
+		goto out;
+	}
 
 	ret = probe_file__get_events(kfd, filter, klist);
 	if (ret == 0) {

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

end of thread, other threads:[~2015-09-18 21:24 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-09-16 12:52 [PATCH perf/core ] [BUGFIX] perf probe: Fix a segfault when removing uprobe events Masami Hiramatsu
2015-09-18  1:39 ` 平松雅巳 / HIRAMATU,MASAMI
2015-09-18 14:26   ` Arnaldo Carvalho de Melo
2015-09-18 14:28     ` Arnaldo Carvalho de Melo
2015-09-18 14:31       ` Arnaldo Carvalho de Melo
2015-09-18 21:24 ` Paul Clarke

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).