perf script: Avoid NULL dereference on symbol
authorIan Rogers <irogers@google.com>
Tue, 21 Apr 2020 00:43:29 +0000 (17:43 -0700)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Wed, 22 Apr 2020 13:59:02 +0000 (10:59 -0300)
al->sym may be NULL given current if conditions and may cause a segv.

Fixes: d2bedb7863e9 ("perf script: Allow --symbol to accept hexadecimal addresses")
Signed-off-by: Ian Rogers <irogers@google.com>
Acked-by: Jiri Olsa <jolsa@redhat.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lore.kernel.org/lkml/20200421004329.43109-1-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/util/event.c

index dc0e112..f581550 100644 (file)
@@ -626,7 +626,7 @@ int machine__resolve(struct machine *machine, struct addr_location *al,
                        ret = strlist__has_entry(symbol_conf.sym_list,
                                                al->sym->name);
                }
-               if (!(ret && al->sym)) {
+               if (!ret && al->sym) {
                        snprintf(al_addr_str, sz, "0x%"PRIx64,
                                al->map->unmap_ip(al->map, al->sym->start));
                        ret = strlist__has_entry(symbol_conf.sym_list,