]> git.proxmox.com Git - mirror_zfs.git/commitdiff
Suppress static analyzer warning in sa_attr_iter()
authorRichard Yao <richard.yao@alumni.stonybrook.edu>
Tue, 7 Feb 2023 08:02:10 +0000 (03:02 -0500)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Wed, 1 Mar 2023 01:31:30 +0000 (17:31 -0800)
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 <behlendorf1@llnl.gov>
Reviewed-by: Brian Atkinson <batkinson@lanl.gov>
Signed-off-by: Richard Yao <richard.yao@alumni.stonybrook.edu>
Reported-by: Coverity (CID-1017954)
Closes #14470

module/zfs/sa.c

index 5568a24b84fe8a6b00aed3bca8ec0549fe4ed454..763b0c920f111a54b48a8cc5fd8ad9cd9d0a7429 100644 (file)
@@ -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;