From: Vincent Fu Date: Tue, 11 Jun 2024 20:09:00 +0000 (-0400) Subject: iolog: check scalloc return value X-Git-Tag: fio-3.38~54 X-Git-Url: https://git.kernel.dk/?a=commitdiff_plain;h=b6eb53b7495e0427307cc599d495ab113bbd08f9;p=fio.git 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 --- 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;