From 7cb67d627c0c258a5dedb5b0d1f979469e51c91a Mon Sep 17 00:00:00 2001 From: Richard Yao Date: Thu, 23 Feb 2023 13:19:08 -0500 Subject: [PATCH] Fix NULL pointer dereference in zio_ready() Clang's static analyzer correctly identified a NULL pointer dereference in zio_ready() when ZIO_FLAG_NODATA has been set on a zio that is missing a block pointer. The NULL pointer dereference occurs because we have logic intended to disable ZIO_FLAG_NODATA when it has been set on a gang block. Reviewed-by: Brian Behlendorf Reviewed-by: Brian Atkinson Signed-off-by: Richard Yao Closes #14469 --- module/zfs/zio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/module/zfs/zio.c b/module/zfs/zio.c index d888a584a9..19b222dfe6 100644 --- a/module/zfs/zio.c +++ b/module/zfs/zio.c @@ -4431,7 +4431,7 @@ zio_ready(zio_t *zio) } if (zio->io_flags & ZIO_FLAG_NODATA) { - if (BP_IS_GANG(bp)) { + if (bp != NULL && BP_IS_GANG(bp)) { zio->io_flags &= ~ZIO_FLAG_NODATA; } else { ASSERT((uintptr_t)zio->io_abd < SPA_MAXBLOCKSIZE);