Skip to content

Commit

Permalink
Suppress Clang Static Analyzer warning in dbuf_dnode_findbp()
Browse files Browse the repository at this point in the history
Clang's static analyzer reports that if a `blkid == DMU_SPILL_BLKID` is
passed, then we can have a NULL pointer dereference when either
->dn_have_spill or `DNODE_FLAG_SPILL_BLKPTR` is not set. This should not
happen. We add an `ASSERT()` to suppress reports about NULL pointer
dereferences.

Originally, I wanted to use one or two IMPLY statements on
pre-conditions before the call to `dbuf_findbp()`, but Clang's static
analyzer did not understand it.

Reviewed-by: Brian Behlendorf <[email protected]>
Signed-off-by: Richard Yao <[email protected]>
Closes openzfs#14575
  • Loading branch information
ryao authored and datacore-rm committed Aug 14, 2023
1 parent 9036606 commit 6a9db83
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions module/zfs/dbuf.c
Original file line number Diff line number Diff line change
Expand Up @@ -3136,6 +3136,7 @@ dbuf_dnode_findbp(dnode_t *dn, uint64_t level, uint64_t blkid,

err = dbuf_findbp(dn, level, blkid, B_FALSE, &dbp, &bp2);
if (err == 0) {
ASSERT3P(bp2, !=, NULL);
*bp = *bp2;
if (dbp != NULL)
dbuf_rele(dbp, NULL);
Expand Down

0 comments on commit 6a9db83

Please sign in to comment.