aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnkit Kumar <ankit.kumar@samsung.com>2024-01-26 05:03:28 +0530
committerAnkit Kumar <ankit.kumar@samsung.com>2024-01-26 06:52:50 +0530
commitacc481b6d34aab3ee6e19f22b64f8bf0dd30480c (patch)
treeac15efa141b9ded2b4b2dd45ce2490331e836b2b
parent4502ad2c5b18085a2f4f5a71741ef0ca24cdaf38 (diff)
downloadfio-acc481b6d34aab3ee6e19f22b64f8bf0dd30480c.tar.gz
iolog: fix reported defect from coverity scan
Fix the two Null pointer dereferences issue reported by Coverity scan Null pointer dereferences (FORWARD_NULL) Dereferencing null pointer "l->td" Null pointer dereferences (REVERSE_INULL) Null-checking "p->td" suggests that it may be null, but it has already been dereferenced on all paths leading to the check. For aggregate read, write and trim bandwidth log, the setup_log function gets called with NULL pointer reference for thread data. Thus before dereferencing further we should check "l->td". Signed-off-by: Ankit Kumar <ankit.kumar@samsung.com>
-rw-r--r--iolog.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/iolog.c b/iolog.c
index b4c7a8f13..f52a9a80f 100644
--- a/iolog.c
+++ b/iolog.c
@@ -862,7 +862,12 @@ void setup_log(struct io_log **log, struct log_params *p,
l->log_ddir_mask = LOG_OFFSET_SAMPLE_BIT;
if (l->log_prio)
l->log_ddir_mask |= LOG_PRIO_SAMPLE_BIT;
- if (l->td->o.log_max == IO_LOG_SAMPLE_BOTH)
+ /*
+ * The bandwidth-log option generates agg-read_bw.log,
+ * agg-write_bw.log and agg-trim_bw.log for which l->td is NULL.
+ * Check if l->td is valid before dereferencing it.
+ */
+ if (l->td && l->td->o.log_max == IO_LOG_SAMPLE_BOTH)
l->log_ddir_mask |= LOG_AVG_MAX_SAMPLE_BIT;
INIT_FLIST_HEAD(&l->chunk_list);