[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220125121141.18347-1-amhamza.mgc@gmail.com>
Date: Tue, 25 Jan 2022 17:11:41 +0500
From: Ameer Hamza <amhamza.mgc@...il.com>
To: mark.rutland@....com, alexander.shishkin@...ux.intel.com,
jolsa@...hat.com, namhyung@...nel.org
Cc: peterz@...radead.org, mingo@...hat.com, acme@...nel.org,
rickyman7@...il.com, alexey.v.bayduraev@...ux.intel.com,
adrian.hunter@...el.com, leo.yan@...aro.org, german.gomez@....com,
linux-perf-users@...r.kernel.org, linux-kernel@...r.kernel.org,
amhamza.mgc@...il.com, James Clark <james.clark@....com>
Subject: [PATCH v2] perf session: check for null pointer before derefernce
Move null pointer check before dereferncing the variable
Addresses-Coverity: 1497622 ("Derereference before null check")
Reviewed-by: James Clark <james.clark@....com>
Signed-off-by: Ameer Hamza <amhamza.mgc@...il.com>
---
v1 -> v2: It should be possible to dump stuff if machine is NULL.
---
tools/perf/util/session.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
index f19348dddd55..210eeee3dd70 100644
--- a/tools/perf/util/session.c
+++ b/tools/perf/util/session.c
@@ -1503,11 +1503,12 @@ static int machines__deliver_event(struct machines *machines,
++evlist->stats.nr_unknown_id;
return 0;
}
- dump_sample(evsel, event, sample, perf_env__arch(machine->env));
if (machine == NULL) {
++evlist->stats.nr_unprocessable_samples;
+ dump_sample(evsel, event, sample, perf_env__arch(NULL));
return 0;
}
+ dump_sample(evsel, event, sample, perf_env__arch(machine->env));
return evlist__deliver_sample(evlist, tool, event, sample, evsel, machine);
case PERF_RECORD_MMAP:
return tool->mmap(tool, event, sample, machine);
--
2.25.1
Powered by blists - more mailing lists