From a15118757dad19c7f17700903d169676f244e318 Mon Sep 17 00:00:00 2001 From: Vincent Fu Date: Tue, 11 Jun 2024 16:19:38 -0400 Subject: [PATCH] helper_thread: check for null scalloc return value scalloc can return NULL if it fails to allocate memory. Check for this condition and fail the helper thread setup if it occurs. This issue was reported by Coverity: ** CID 496644: Null pointer dereferences (NULL_RETURNS) /helper_thread.c: 425 in helper_thread_create() 419 420 hd = scalloc(1, sizeof(*hd)); 421 422 setup_disk_util(); 423 steadystate_setup(); 424 >>> CID 496644: Null pointer dereferences (NULL_RETURNS) >>> Dereferencing "hd", which is known to be "NULL". 425 hd->sk_out = sk_out; Signed-off-by: Vincent Fu --- helper_thread.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/helper_thread.c b/helper_thread.c index 332ccb53..fed21d1d 100644 --- a/helper_thread.c +++ b/helper_thread.c @@ -418,6 +418,8 @@ int helper_thread_create(struct fio_sem *startup_sem, struct sk_out *sk_out) int ret; hd = scalloc(1, sizeof(*hd)); + if (!hd) + return 1; setup_disk_util(); steadystate_setup(); -- 2.25.1