perf probe: Fix a segfault when removing uprobe events
authorMasami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Wed, 16 Sep 2015 12:52:42 +0000 (21:52 +0900)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Mon, 21 Sep 2015 21:01:17 +0000 (18:01 -0300)
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>
Cc: Namhyung Kim <namhyung@kernel.org>
Link: http://lkml.kernel.org/r/20150916125241.4446.44805.stgit@localhost.localdomain
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/builtin-probe.c

index 94385ee89dc89af9f50b126da068c3173a05955c..f7882ae9ebc68b9674b4960e0a000ddc1972fef8 100644 (file)
@@ -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) {