summaryrefslogtreecommitdiffstats
path: root/module
diff options
context:
space:
mode:
authorRichard Yao <[email protected]>2023-03-14 18:00:54 -0400
committerGitHub <[email protected]>2023-03-14 15:00:54 -0700
commit3cb293a6f803fe9ef58a6b6d23d50ca5b688da97 (patch)
tree22094b62b6246ac53381b7f9950330c492b49489 /module
parent3a03c96381117c9fbb3bf842db106fc15326c781 (diff)
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 <[email protected]> Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Richard Yao <[email protected]> Reported-by: Coverity (CID-992298) Closes #14619
Diffstat (limited to 'module')
-rw-r--r--module/zfs/dbuf.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/module/zfs/dbuf.c b/module/zfs/dbuf.c
index 94c2ae9d7..80ea1bfe4 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