stat: fix the null io_u dereference in add_clat_sample()
authorShin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
Fri, 6 Sep 2024 02:37:16 +0000 (11:37 +0900)
committerJens Axboe <axboe@kernel.dk>
Fri, 6 Sep 2024 13:41:43 +0000 (07:41 -0600)
commita0e2faaf7e5d0814f08f8ab337241372fd58be1e
treeec3189a31b95eb8fc6f324fb4ef809ae918c773e
parent65098b11f8aa28e328c225dcd39e3338bb005fdc
stat: fix the null io_u dereference in add_clat_sample()

As recorded in the Link, NULL pointer dereference happens when the
write_lat_log option is specified for the file operations IO engine.
This failure was caused by the commit 14d3134a5fc0 ("introduce the
log_issue_time option") which added the new field 'issue_time' to the
struct log_sample. To calculate the issue time, add_clat_sample() was
modified to refer to io_u->issue_time. However, the file operations IO
engine passes NULL as the io_u pointer. Hence the failure.

Fix this by skipping the io_u->issue_time reference when io_u is NULL.
Instead, set 0 as the issue time.

Link: https://lore.kernel.org/fio/0e2c84c9-f9e4-4073-a075-016393ca7bde@gmail.com/
Fixes: 14d3134a5fc0 ("introduce the log_issue_time option")
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
Link: https://lore.kernel.org/r/20240906023717.1464031-2-shinichiro.kawasaki@wdc.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
stat.c