[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20200720162645.GS9247@paulmck-ThinkPad-P72>
Date: Mon, 20 Jul 2020 09:26:45 -0700
From: "Paul E. McKenney" <paulmck@...nel.org>
To: Colin King <colin.king@...onical.com>
Cc: Josh Triplett <josh@...htriplett.org>,
Steven Rostedt <rostedt@...dmis.org>,
Mathieu Desnoyers <mathieu.desnoyers@...icios.com>,
Lai Jiangshan <jiangshanlai@...il.com>,
Joel Fernandes <joel@...lfernandes.org>, rcu@...r.kernel.org,
kernel-janitors@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH][next] refperf: avoid null pointer dereference when buf
fails to allocate
On Thu, Jul 16, 2020 at 03:38:56PM +0100, Colin King wrote:
> From: Colin Ian King <colin.king@...onical.com>
>
> 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: f518f154ecef ("refperf: Dynamically allocate experiment-summary output buffer")
> Signed-off-by: Colin Ian King <colin.king@...onical.com>
Good catch, applied, thank you!
Thanx, Paul
> ---
> kernel/rcu/refscale.c | 8 +++++---
> 1 file changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/kernel/rcu/refscale.c b/kernel/rcu/refscale.c
> index d9291f883b54..952595c678b3 100644
> --- a/kernel/rcu/refscale.c
> +++ b/kernel/rcu/refscale.c
> @@ -546,9 +546,11 @@ static int main_func(void *arg)
> // Print the average of all experiments
> SCALEOUT("END OF TEST. Calculating average duration per loop (nanoseconds)...\n");
>
> - buf[0] = 0;
> - strcat(buf, "\n");
> - strcat(buf, "Runs\tTime(ns)\n");
> + if (!errexit) {
> + buf[0] = 0;
> + strcat(buf, "\n");
> + strcat(buf, "Runs\tTime(ns)\n");
> + }
>
> for (exp = 0; exp < nruns; exp++) {
> u64 avg;
> --
> 2.27.0
>
Powered by blists - more mailing lists