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>
 
        }
 
 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)