]> git.proxmox.com Git - mirror_zfs.git/commit
Suppress static analyzer warnings in zio_checksum_error_impl()
authorRichard Yao <richard.yao@alumni.stonybrook.edu>
Tue, 7 Feb 2023 07:38:45 +0000 (02:38 -0500)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Wed, 1 Mar 2023 01:31:08 +0000 (17:31 -0800)
commit4d9bb5514c5ab1b025384db3f3c42eca550ff944
tree6e2445e26f5c84f59cec307b3397f9196d8e4086
parentd634d20d1be31dfa8cf06ef2dc96285baf81a2fb
Suppress static analyzer warnings in zio_checksum_error_impl()

Clang's static analyzer informs us of multiple NULL pointer dereferences
involving zio_checksum_error_impl().

The first is a NULL pointer dereference if bp is NULL and ci->ci_flags &
ZCHECKSUM_FLAG_EMBEDDED is false, but bp is NULL implies that
ci->ci_flags & ZCHECKSUM_FLAG_EMBEDDED is true, so we add an IMPLY()
statement to suppress the report.

The second and third are identical, and are duplicated because while the
NULL pointer dereference occurs in zio_checksum_gang_verifier(), it is
called by zio_checksum_error_impl() and there is a report for each of
the two functions. The reports state that when bp is NULL, ci->ci_flags
& ZCHECKSUM_FLAG_EMBEDDED is true and checksum is not
ZIO_CHECKSUM_LABEL, we also have a NULL pointer dereference. bp is NULL
should imply that checksum == ZIO_CHECKSUM_LABEL, so we add an IMPLY()
statement to suppress the second report. The two reports are
functionally identical.

A fourth variation of this was also reported by Coverity. It occurs when
checksum == ZIO_CHECKSUM_ZILOG2.

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-1524672)
Closes #14470
module/zfs/zio_checksum.c