Skip to content

Commit

Permalink
stat: fix the null io_u dereference in add_clat_sample()
Browse files Browse the repository at this point in the history
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 14d3134 ("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/[email protected]/
Fixes: 14d3134 ("introduce the log_issue_time option")
Signed-off-by: Shin'ichiro Kawasaki <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Jens Axboe <[email protected]>
  • Loading branch information
kawasaki authored and axboe committed Sep 6, 2024
1 parent 65098b1 commit a0e2faa
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions stat.c
Original file line number Diff line number Diff line change
Expand Up @@ -3340,8 +3340,11 @@ void add_clat_sample(struct thread_data *td, enum fio_ddir ddir,

if (td->clat_log) {
struct log_sample sample = { sample_val(nsec), ddir, bs,
offset, ioprio,
ntime_since(&td->epoch, &io_u->issue_time) };
offset, ioprio, 0 };

if (io_u)
sample.issue_time =
ntime_since(&td->epoch, &io_u->issue_time);

add_log_sample(td, td->clat_log, &sample);
}
Expand Down

0 comments on commit a0e2faa

Please sign in to comment.