lkml.org 
[lkml]   [2020]   [Oct]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 5.9 405/757] refperf: Avoid null pointer dereference when buf fails to allocate
    Date
    From: Colin Ian King <colin.king@canonical.com>

    [ Upstream commit 58db5785b0d76be4582a32a7900acce88e691d36 ]

    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@canonical.com>
    Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    ---
    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 d9291f883b542..952595c678b37 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.25.1


    \
     
     \ /
      Last update: 2020-10-27 17:11    [W:2.559 / U:0.072 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site