mirror of
https://github.com/torvalds/linux
synced 2024-09-20 02:57:25 +00:00
refperf: Avoid null pointer dereference when buf fails to allocate
Currently in the unlikely event that buf fails to be allocated it
is dereferenced a few times. Use the errexit flag to determine if
buf should be written to to avoid the null pointer dereferences.
Addresses-Coverity: ("Dereference after null check")
Fixes: f518f154ec
("refperf: Dynamically allocate experiment-summary output buffer")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
This commit is contained in:
parent
57f602022e
commit
58db5785b0
|
@ -546,9 +546,11 @@ static int main_func(void *arg)
|
||||||
// Print the average of all experiments
|
// Print the average of all experiments
|
||||||
SCALEOUT("END OF TEST. Calculating average duration per loop (nanoseconds)...\n");
|
SCALEOUT("END OF TEST. Calculating average duration per loop (nanoseconds)...\n");
|
||||||
|
|
||||||
buf[0] = 0;
|
if (!errexit) {
|
||||||
strcat(buf, "\n");
|
buf[0] = 0;
|
||||||
strcat(buf, "Runs\tTime(ns)\n");
|
strcat(buf, "\n");
|
||||||
|
strcat(buf, "Runs\tTime(ns)\n");
|
||||||
|
}
|
||||||
|
|
||||||
for (exp = 0; exp < nruns; exp++) {
|
for (exp = 0; exp < nruns; exp++) {
|
||||||
u64 avg;
|
u64 avg;
|
||||||
|
|
Loading…
Reference in a new issue