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