stat: make free_clat_prio_stats() safe against NULL
authorNiklas Cassel <niklas.cassel@wdc.com>
Fri, 4 Feb 2022 00:17:49 +0000 (00:17 +0000)
committerJens Axboe <axboe@kernel.dk>
Fri, 4 Feb 2022 00:18:58 +0000 (17:18 -0700)
commite23aa8174d6a1242d81491ce30f10a8d5f9acb10
treee32437b373969b28118c3494922ad47453d0cdc4
parent62e9ece4d540ff2af865e4b43811f3150b8b846b
stat: make free_clat_prio_stats() safe against NULL

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@wdc.com>
Link: https://lore.kernel.org/r/20220204001741.34419-1-Niklas.Cassel@wdc.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
stat.c