From a6ccb36b948efed0eeee4fcf99fe4b5fb81ae1d5 Mon Sep 17 00:00:00 2001 From: Richard Yao Date: Wed, 12 Oct 2022 14:25:18 -0400 Subject: 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 Signed-off-by: Richard Yao Closes #13972 --- module/os/linux/zfs/zfs_acl.c | 1 + 1 file changed, 1 insertion(+) (limited to 'module/os/linux/zfs/zfs_acl.c') diff --git a/module/os/linux/zfs/zfs_acl.c b/module/os/linux/zfs/zfs_acl.c index 5935403b4..d5cd5de89 100644 --- a/module/os/linux/zfs/zfs_acl.c +++ b/module/os/linux/zfs/zfs_acl.c @@ -1163,6 +1163,7 @@ zfs_acl_data_locator(void **dataptr, uint32_t *length, uint32_t buflen, cb->cb_acl_node = list_next(&cb->cb_aclp->z_acl, cb->cb_acl_node); } + ASSERT3P(cb->cb_acl_node, !=, NULL); *dataptr = cb->cb_acl_node->z_acldata; *length = cb->cb_acl_node->z_size; } -- cgit v1.2.3