summaryrefslogtreecommitdiffstats
path: root/tools/perf
diff options
context:
space:
mode:
authorArnaldo Carvalho de Melo2019-07-03 21:02:09 +0200
committerArnaldo Carvalho de Melo2019-07-09 14:33:55 +0200
commit40978e9bf2137223993e70921de2731201788049 (patch)
tree6a30fc456b6dbed75fc7a8def8ee6b9fb284b836 /tools/perf
parentperf map: Fix potential NULL pointer dereference found by smatch tool (diff)
downloadkernel-qcow2-linux-40978e9bf2137223993e70921de2731201788049.tar.gz
kernel-qcow2-linux-40978e9bf2137223993e70921de2731201788049.tar.xz
kernel-qcow2-linux-40978e9bf2137223993e70921de2731201788049.zip
perf inject: The tool->read() call may pass a NULL evsel, handle it
Check first, as machines__deliver_event() may have perf_evlist__id2evsel() returning NULL. This was found while checking a report from Leo Yan that used the smatch tool to find places where a pointer is checked before use and then, later in the same function gets used without checking. Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Leo Yan <leo.yan@linaro.org> Cc: Namhyung Kim <namhyung@kernel.org> Link: https://lkml.kernel.org/n/tip-muvb8xqyh0gysgfjfq35w642@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf')
-rw-r--r--tools/perf/builtin-inject.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/tools/perf/builtin-inject.c b/tools/perf/builtin-inject.c
index 8e0e06d3edfc..f4591a1438b4 100644
--- a/tools/perf/builtin-inject.c
+++ b/tools/perf/builtin-inject.c
@@ -224,7 +224,7 @@ static int perf_event__repipe_sample(struct perf_tool *tool,
struct perf_evsel *evsel,
struct machine *machine)
{
- if (evsel->handler) {
+ if (evsel && evsel->handler) {
inject_handler f = evsel->handler;
return f(tool, event, sample, evsel, machine);
}