From 3cb293a6f803fe9ef58a6b6d23d50ca5b688da97 Mon Sep 17 00:00:00 2001 From: Richard Yao Date: Tue, 14 Mar 2023 18:00:54 -0400 Subject: [PATCH] Fix possible NULL pointer dereference in dbuf_verify() Coverity reported a dereference after a NULL check in dbuf_verify(). If `dn` is `NULL`, we can just assume that !dn->dn_free_txg, so we change `!dn->dn_free_txg` to `(dn == NULL || !dn->dn_free_txg)`. Reviewed-by: Tino Reichardt Reviewed-by: Brian Behlendorf Signed-off-by: Richard Yao Reported-by: Coverity (CID-992298) Closes #14619 --- module/zfs/dbuf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/module/zfs/dbuf.c b/module/zfs/dbuf.c index 94c2ae9d73..80ea1bfe41 100644 --- a/module/zfs/dbuf.c +++ b/module/zfs/dbuf.c @@ -1157,7 +1157,7 @@ dbuf_verify(dmu_buf_impl_t *db) if ((db->db_blkptr == NULL || BP_IS_HOLE(db->db_blkptr)) && (db->db_buf == NULL || db->db_buf->b_data) && db->db.db_data && db->db_blkid != DMU_BONUS_BLKID && - db->db_state != DB_FILL && !dn->dn_free_txg) { + db->db_state != DB_FILL && (dn == NULL || !dn->dn_free_txg)) { /* * If the blkptr isn't set but they have nonzero data, * it had better be dirty, otherwise we'll lose that