]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - rpmsg/rpmsg.git/commitdiff
perf callchain: Fix segfault in thread__resolve_callchain_sample()
authorAdrian Hunter <adrian.hunter@intel.com>
Thu, 14 Nov 2019 14:25:38 +0000 (16:25 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 17 Dec 2019 19:35:51 +0000 (20:35 +0100)
[ Upstream commit aceb98261ea7d9fe38f9c140c5531f0b13623832 ]

Do not dereference 'chain' when it is NULL.

  $ perf record -e intel_pt//u -e branch-misses:u uname
  $ perf report --itrace=l --branch-history
  perf: Segmentation fault

Fixes: e9024d519d89 ("perf callchain: Honour the ordering of PERF_CONTEXT_{USER,KERNEL,etc}")
Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Link: http://lore.kernel.org/lkml/20191114142538.4097-1-adrian.hunter@intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
tools/perf/util/machine.c

index 003b70daf0bfc9310feff31bfc377e822aa7e25a..21f867a543e0286729195704baa7543d3c6c94da 100644 (file)
@@ -2276,7 +2276,7 @@ static int thread__resolve_callchain_sample(struct thread *thread,
        }
 
 check_calls:
-       if (callchain_param.order != ORDER_CALLEE) {
+       if (chain && callchain_param.order != ORDER_CALLEE) {
                err = find_prev_cpumode(chain, thread, cursor, parent, root_al,
                                        &cpumode, chain->nr - first_call);
                if (err)