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 <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
This commit is contained in:
Richard Yao 2023-02-07 03:02:10 -05:00 committed by Brian Behlendorf
parent 4d9bb5514c
commit 7fc48f8378
1 changed files with 1 additions and 0 deletions

View 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; uint8_t idx_len;
reg_length = sa->sa_attr_table[tb->lot_attrs[i]].sa_length; reg_length = sa->sa_attr_table[tb->lot_attrs[i]].sa_length;
IMPLY(reg_length == 0, IS_SA_BONUSTYPE(type));
if (reg_length) { if (reg_length) {
attr_length = reg_length; attr_length = reg_length;
idx_len = 0; idx_len = 0;