From 824d8186d4fff69e95163cb3272246e03d4213fa Mon Sep 17 00:00:00 2001 From: Erwan Velu Date: Wed, 8 Sep 2021 22:35:59 +0200 Subject: [PATCH] stat: Avoid freeing null pointer 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 --- stat.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/stat.c b/stat.c index 99275620..ac53463d 100644 --- 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); } -- 2.25.1