From: Niklas Cassel <niklas.cassel@xxxxxxx> The sfree() in free_clat_prio_stats() itself handles NULL, so the function already handles a struct thread_stat without any per priority stats. (Per priority stats are disabled on threads/thread_stats that we know will never be able to contain more than a single priority.) However, if malloc() in e.g. gen_mixed_ddir_stats_from_ts() or __show_run_stats() failed to allocate memory, free_clat_prio_stats() will be supplied a NULL pointer. Fix free_clat_prio_stats() to handle a NULL pointer gracefully. Fixes: 4ad856497c0b ("stat: add a new function to allocate a clat_prio_stat array") Signed-off-by: Niklas Cassel <niklas.cassel@xxxxxxx> --- stat.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/stat.c b/stat.c index 0876222a..1764eebc 100644 --- a/stat.c +++ b/stat.c @@ -2041,6 +2041,9 @@ void free_clat_prio_stats(struct thread_stat *ts) { enum fio_ddir ddir; + if (!ts) + return; + for (ddir = 0; ddir < DDIR_RWDIR_CNT; ddir++) { sfree(ts->clat_prio[ddir]); ts->clat_prio[ddir] = NULL; -- 2.34.1