From 7fc48f8378c608bde79e815f8a3e95a4f2045314 Mon Sep 17 00:00:00 2001 From: Richard Yao Date: Tue, 7 Feb 2023 03:02:10 -0500 Subject: [PATCH] Suppress static analyzer warning in sa_attr_iter() Clang's static analyzer points out that when IS_SA_BONUSTYPE(type) is true and .sa_length is 0 for an attribute, we have a NULL pointer dereference. We suppress this with an IMPLY() statement. This was also identified by Coverity. Reviewed-by: Brian Behlendorf Reviewed-by: Brian Atkinson Signed-off-by: Richard Yao Reported-by: Coverity (CID-1017954) Closes #14470 --- module/zfs/sa.c | 1 + 1 file changed, 1 insertion(+) diff --git a/module/zfs/sa.c b/module/zfs/sa.c index 5568a24b8..763b0c920 100644 --- a/module/zfs/sa.c +++ b/module/zfs/sa.c @@ -1201,6 +1201,7 @@ sa_attr_iter(objset_t *os, sa_hdr_phys_t *hdr, dmu_object_type_t type, uint8_t idx_len; reg_length = sa->sa_attr_table[tb->lot_attrs[i]].sa_length; + IMPLY(reg_length == 0, IS_SA_BONUSTYPE(type)); if (reg_length) { attr_length = reg_length; idx_len = 0;