OSDN Git Service

perf parse-events: Add defensive NULL check
authorIan Rogers <irogers@google.com>
Wed, 25 Mar 2020 16:40:22 +0000 (09:40 -0700)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Thu, 26 Mar 2020 14:03:53 +0000 (11:03 -0300)
commit2a3d252dffe14582f238e21b09923e3772263123
treecb67cbb3ee36130d7f5f7744bcd306613f173056
parenteadcaa3dfd706bbf46682c8b8b5979262443c3c3
perf parse-events: Add defensive NULL check

Terms may have a NULL config in which case a strcmp will SEGV. This can
be reproduced with:

  perf stat -e '*/event=?,nr/' sleep 1

Add a NULL check to avoid this. This was caught by LLVM's libfuzzer.

Signed-off-by: Ian Rogers <irogers@google.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Jin Yao <yao.jin@linux.intel.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: John Garry <john.garry@huawei.com>
Cc: Kan Liang <kan.liang@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>
Cc: clang-built-linux@googlegroups.com
Link: http://lore.kernel.org/lkml/20200325164022.41385-1-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/util/pmu.c