Skip to content

Commit

Permalink
Suppress Clang Static Analyzer defect report in abd_get_size()
Browse files Browse the repository at this point in the history
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 openzfs#14575
  • Loading branch information
ryao authored and behlendorf committed Mar 8, 2023
1 parent 9368b38 commit 8b72dfe
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions module/zfs/vdev_draid.c
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
uint64_t tot = psize + (vdc->vdc_nparity * (q + (r == 0 ? 0 : 1)));

ASSERT3U(vdc->vdc_nparity, >, 0);

raidz_row_t *rr;
rr = kmem_alloc(offsetof(raidz_row_t, rr_col[groupwidth]), KM_SLEEP);
rr->rr_cols = groupwidth;
Expand Down

0 comments on commit 8b72dfe

Please sign in to comment.