perf top: Fix error handling in cmd_top()
authorChangbin Du <[email protected]>
Sat, 16 Mar 2019 08:05:48 +0000 (16:05 +0800)
committerArnaldo Carvalho de Melo <[email protected]>
Tue, 19 Mar 2019 19:52:04 +0000 (16:52 -0300)
We should go to the cleanup path, to avoid leaks, detected using gcc's
ASan.

Signed-off-by: Changbin Du <[email protected]>
Reviewed-by: Jiri Olsa <[email protected]>
Cc: Alexei Starovoitov <[email protected]>
Cc: Daniel Borkmann <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Steven Rostedt (VMware) <[email protected]>
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
tools/perf/builtin-top.c

index 614f278235fa3e1be37897aa18f97f00f388734f..2508a7a552faacbb85a236824a01c21a69e6fe23 100644 (file)
@@ -1617,8 +1617,9 @@ int cmd_top(int argc, const char **argv)
        annotation_config__init();
 
        symbol_conf.try_vmlinux_path = (symbol_conf.vmlinux_name == NULL);
-       if (symbol__init(NULL) < 0)
-               return -1;
+       status = symbol__init(NULL);
+       if (status < 0)
+               goto out_delete_evlist;
 
        sort__setup_elide(stdout);