From a70e681c58b0da219dd57749df6e7c97607b29bf Mon Sep 17 00:00:00 2001 From: Hyunwoo Park Date: Thu, 30 May 2024 02:15:05 +0000 Subject: [PATCH 1/2] iolog: fix Null pointer dereferences (FORWARD_NULL) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit CID 494150: Null pointer dereferences (FORWARD_NULL) @ iolog.c:148 in ipo_special() This patch removes the possibility of null pointer dereferencing(io_u->file) throughout the call stack of get_io_u() → read_iolog_get() → dp_fill_dspec_data() Signed-off-by: Hyunwoo Park --- iolog.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/iolog.c b/iolog.c index 37ad0d2a16..e3a56db957 100644 --- a/iolog.c +++ b/iolog.c @@ -236,15 +236,15 @@ int read_iolog_get(struct thread_data *td, struct io_u *io_u) io_u->buflen, io_u->file->file_name); if (ipo->delay) iolog_delay(td, ipo->delay); + + if (td->o.dp_type != FIO_DP_NONE) + dp_fill_dspec_data(td, io_u); } else { elapsed = mtime_since_genesis(); if (ipo->delay > elapsed) usec_sleep(td, (ipo->delay - elapsed) * 1000); } - if (td->o.dp_type != FIO_DP_NONE) - dp_fill_dspec_data(td, io_u); - free(ipo); if (io_u->ddir != DDIR_WAIT) From 4150d2e91e8a38b967db5cee7d5681187f0d2088 Mon Sep 17 00:00:00 2001 From: Hyunwoo Park Date: Thu, 30 May 2024 02:48:57 +0000 Subject: [PATCH 2/2] iolog: fix Error handling issues (NEGATIVE_RETURNS) CID 494151: Error handling issues (NEGATIVE_RETURNS) @ io_u.c:1877 in get_io_u() This patch removes negative returns from dp_init() to ensure its value can be properly consumed by td_verror() Signed-off-by: Hyunwoo Park --- iolog.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iolog.c b/iolog.c index e3a56db957..b57f845e27 100644 --- a/iolog.c +++ b/iolog.c @@ -145,7 +145,7 @@ static int ipo_special(struct thread_data *td, struct io_piece *ipo) int dp_init_ret = dp_init(td); if (dp_init_ret != 0) { - td_verror(td, dp_init_ret, "dp_init"); + td_verror(td, abs(dp_init_ret), "dp_init"); return -1; } }