Add defensive assertions

Coverity complains about possible bugs involving referencing NULL return
values and division by zero. The division by zero bugs require that a
block pointer be corrupt, either from in-memory corruption, or on-disk
corruption. The NULL return value complaints are only bugs if
assumptions that we make about the state of data structures are wrong.
Some seem impossible to be wrong and thus are false positives, while
others are hard to analyze.

Rather than dismiss these as false positives by assuming we know better,
we add defensive assertions to let us know when our assumptions are
wrong.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Richard Yao <richard.yao@alumni.stonybrook.edu>
Closes #13972
This commit is contained in:
Richard Yao
2022-10-12 14:25:18 -04:00
committed by GitHub
parent bfaa1d98f4
commit a6ccb36b94
14 changed files with 17 additions and 1 deletions
+3 -1
View File
@@ -303,8 +303,10 @@ mmp_next_leaf(spa_t *spa)
do {
leaf = list_next(&spa->spa_leaf_list, leaf);
if (leaf == NULL)
if (leaf == NULL) {
leaf = list_head(&spa->spa_leaf_list);
ASSERT3P(leaf, !=, NULL);
}
/*
* We skip unwritable, offline, detached, and dRAID spare