perf probe-file: Delete namelist in del_events() on the error path
authorRiccardo Mancini <rickyman7@gmail.com>
Thu, 15 Jul 2021 16:07:25 +0000 (18:07 +0200)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Sun, 18 Jul 2021 12:27:37 +0000 (09:27 -0300)
ASan reports some memory leaks when running:

  # perf test "42: BPF filter"

This second leak is caused by a strlist not being dellocated on error
inside probe_file__del_events.

This patch adds a goto label before the deallocation and makes the error
path jump to it.

Signed-off-by: Riccardo Mancini <rickyman7@gmail.com>
Fixes: e7895e422e4da63d ("perf probe: Split del_perf_probe_events()")
Cc: Ian Rogers <irogers@google.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lore.kernel.org/lkml/174963c587ae77fa108af794669998e4ae558338.1626343282.git.rickyman7@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/util/probe-file.c

index f9a6cbc..3d50de3 100644 (file)
@@ -377,11 +377,11 @@ int probe_file__del_events(int fd, struct strfilter *filter)
 
        ret = probe_file__get_events(fd, filter, namelist);
        if (ret < 0)
-               return ret;
+               goto out;
 
        ret = probe_file__del_strlist(fd, namelist);
+out:
        strlist__delete(namelist);
-
        return ret;
 }