]> git.proxmox.com Git - mirror_zfs.git/commitdiff
Suppress Clang Static Analyzer warning in dbuf_dnode_findbp()
authorRichard Yao <richard.yao@alumni.stonybrook.edu>
Sat, 4 Mar 2023 21:11:49 +0000 (16:11 -0500)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Wed, 8 Mar 2023 21:51:36 +0000 (13:51 -0800)
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 <behlendorf1@llnl.gov>
Signed-off-by: Richard Yao <richard.yao@alumni.stonybrook.edu>
Closes #14575

module/zfs/dbuf.c

index 427aab50856efe9adc4b470729ad4aa6002bb851..f1d2f61e73416cafa7ea818409426597d91b750e 100644 (file)
@@ -3187,6 +3187,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);