Suppress Clang Static Analyzer defect report in abd_get_size()

Clang's static analyzer reports a possible NULL pointer dereference in
abd_get_size() when called from vdev_draid_map_alloc_write() called from
vdev_draid_map_alloc_row() and vdc->vdc_nparity == 0. This should be
impossible, so we add an assertion to silence the defect report.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Richard Yao <richard.yao@alumni.stonybrook.edu>
Closes #14575
This commit is contained in:
Richard Yao 2023-02-07 18:47:40 -05:00 committed by Brian Behlendorf
parent 9368b3877c
commit 8b72dfed11

View File

@ -1023,6 +1023,8 @@ vdev_draid_map_alloc_row(zio_t *zio, raidz_row_t **rrp, uint64_t io_offset,
/* The total number of data and parity sectors for this I/O. */ /* The total number of data and parity sectors for this I/O. */
uint64_t tot = psize + (vdc->vdc_nparity * (q + (r == 0 ? 0 : 1))); uint64_t tot = psize + (vdc->vdc_nparity * (q + (r == 0 ? 0 : 1)));
ASSERT3U(vdc->vdc_nparity, >, 0);
raidz_row_t *rr; raidz_row_t *rr;
rr = kmem_alloc(offsetof(raidz_row_t, rr_col[groupwidth]), KM_SLEEP); rr = kmem_alloc(offsetof(raidz_row_t, rr_col[groupwidth]), KM_SLEEP);
rr->rr_cols = groupwidth; rr->rr_cols = groupwidth;