From b6eb53b7495e0427307cc599d495ab113bbd08f9 Mon Sep 17 00:00:00 2001 From: Vincent Fu Date: Tue, 11 Jun 2024 16:09:00 -0400 Subject: [PATCH] iolog: check scalloc return value It is possible for scalloc to return NULL. setup_log() does not return a value to indicate failure but we can use an assert here to check for a NULL scalloc return value. This will trigger an exception similar to the segfault that would happen if scalloc returns null, but this should silence Coverity. This was reported by Coverity: ** CID 496646: Null pointer dereferences (NULL_RETURNS) /iolog.c: 843 in setup_log() *** CID 496646: Null pointer dereferences (NULL_RETURNS) /iolog.c: 843 in setup_log() 837 struct io_log *l; 838 int i; 839 struct io_u_plat_entry *entry; 840 struct flist_head *list; 841 842 l = scalloc(1, sizeof(*l)); >>> CID 496646: Null pointer dereferences (NULL_RETURNS) >>> Dereferencing "l", which is known to be "NULL". Signed-off-by: Vincent Fu --- iolog.c | 1 + 1 file changed, 1 insertion(+) diff --git a/iolog.c b/iolog.c index b57f845e..f727c97f 100644 --- a/iolog.c +++ b/iolog.c @@ -840,6 +840,7 @@ void setup_log(struct io_log **log, struct log_params *p, struct flist_head *list; l = scalloc(1, sizeof(*l)); + assert(l); INIT_FLIST_HEAD(&l->io_logs); l->log_type = p->log_type; l->log_offset = p->log_offset; -- 2.25.1