[PATCH 1/2] stat: fix the null io_u dereference in add_clat_sample()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx/
Fixes: 14d3134a5fc0 ("introduce the log_issue_time option")
Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@xxxxxxx>
---
 stat.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/stat.c b/stat.c
index 2cfd6819..c5413f2f 100644
--- a/stat.c
+++ b/stat.c
@@ -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);
 	}
-- 
2.45.2





[Index of Archives]     [Linux Kernel]     [Linux SCSI]     [Linux IDE]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux SCSI]

  Powered by Linux