stat: Avoid freeing null pointer
authorErwan Velu <erwanaliasr1@gmail.com>
Wed, 8 Sep 2021 20:35:59 +0000 (22:35 +0200)
committerErwan Velu <erwanaliasr1@gmail.com>
Wed, 8 Sep 2021 20:35:59 +0000 (22:35 +0200)
If ovals is NULL, the jump to out will free(ovals) and will trigger an error.
As the out label was only used for this condition, let's remove it and return immediately.
As out was also used as a variable name, this makes the function easier
to read and more robust.

Signed-off-by: Erwan Velu <erwanaliasr1@gmail.com>
stat.c

diff --git a/stat.c b/stat.c
index 99275620b69d7d5fcac471fbe0426b65d96534c2..ac53463d04642026512d8e9db961483c29dee1fe 100644 (file)
--- a/stat.c
+++ b/stat.c
@@ -211,7 +211,7 @@ static void show_clat_percentiles(uint64_t *io_u_plat, unsigned long long nr,
 
        len = calc_clat_percentiles(io_u_plat, nr, plist, &ovals, &maxv, &minv);
        if (!len || !ovals)
-               goto out;
+               return;
 
        /*
         * We default to nsecs, but if the value range is such that we
@@ -258,7 +258,6 @@ static void show_clat_percentiles(uint64_t *io_u_plat, unsigned long long nr,
                        log_buf(out, "\n");
        }
 
-out:
        free(ovals);
 }