diff options
author | Richard Yao <[email protected]> | 2023-02-07 02:38:45 -0500 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2023-02-28 17:31:08 -0800 |
commit | 4d9bb5514c5ab1b025384db3f3c42eca550ff944 (patch) | |
tree | 6e2445e26f5c84f59cec307b3397f9196d8e4086 /module/zfs | |
parent | d634d20d1be31dfa8cf06ef2dc96285baf81a2fb (diff) |
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 <[email protected]>
Reviewed-by: Brian Atkinson <[email protected]>
Signed-off-by: Richard Yao <[email protected]>
Reported-by: Coverity (CID-1524672)
Closes #14470
Diffstat (limited to 'module/zfs')
-rw-r--r-- | module/zfs/zio_checksum.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/module/zfs/zio_checksum.c b/module/zfs/zio_checksum.c index 37cd35bc8..3743eaa53 100644 --- a/module/zfs/zio_checksum.c +++ b/module/zfs/zio_checksum.c @@ -423,6 +423,9 @@ zio_checksum_error_impl(spa_t *spa, const blkptr_t *bp, zio_checksum_template_init(checksum, spa); + IMPLY(bp == NULL, ci->ci_flags & ZCHECKSUM_FLAG_EMBEDDED); + IMPLY(bp == NULL, checksum == ZIO_CHECKSUM_LABEL); + if (ci->ci_flags & ZCHECKSUM_FLAG_EMBEDDED) { zio_cksum_t verifier; size_t eck_offset; |