From 5cc49509013db4aa23f8e21eafdbde8403d5dffa Mon Sep 17 00:00:00 2001 From: Richard Yao Date: Tue, 7 Feb 2023 04:51:56 -0500 Subject: [PATCH] Suppress static analyzer warning in dbuf_hold_copy() Clang's static analyzer claims that dbuf_hold_copy() will have a NULL pointer dereference in data->b_data when called by dbuf_hold_impl(). This is impossible because data is dr->dt.dl.dr_data, which is non-NULL whenever db->db_level == 0, which is always the case whenever dbuf_hold_impl() calls dbuf_hold_copy(). We add an assertion to suppress the complaint. Reviewed-by: Brian Behlendorf Reviewed-by: Brian Atkinson Signed-off-by: Richard Yao Closes #14470 --- module/zfs/dbuf.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/module/zfs/dbuf.c b/module/zfs/dbuf.c index efaa13317b..160557fce9 100644 --- a/module/zfs/dbuf.c +++ b/module/zfs/dbuf.c @@ -3632,8 +3632,10 @@ dbuf_hold_impl(dnode_t *dn, uint8_t level, uint64_t blkid, dn->dn_object != DMU_META_DNODE_OBJECT && db->db_state == DB_CACHED && db->db_data_pending) { dbuf_dirty_record_t *dr = db->db_data_pending; - if (dr->dt.dl.dr_data == db->db_buf) + if (dr->dt.dl.dr_data == db->db_buf) { + ASSERT3P(db->db_buf, !=, NULL); dbuf_hold_copy(dn, db); + } } if (multilist_link_active(&db->db_cache_link)) {