HomeFreeBSD

Cleanup spa_export_common()

Description

Cleanup spa_export_common()

Coverity complains about a possible NULL pointer dereference. This is
impossible, but it suspects it because we do a NULL check against
spa->spa_root_vdev. This NULL check was never necessary and makes the
code harder to understand, so we drop it.

In particular, we dereference spa->spa_root_vdev when `new_state !=
POOL_STATE_UNINITIALIZED && !hardforce`. The first is only true when
spa_reset is called, which only occurs under fault injection. The
second is true unless zpool export -F $POOLNAME is used. Therefore,
we effectively *always* dereference the pointer. In the cases where we
do not, there is no reason to think it is unsafe. Therefore this change
is safe to make.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Richard Yao <richard.yao@alumni.stonybrook.edu>
Closes #13905

Details

Provenance
Richard Yao <richard.yao@alumni.stonybrook.edu>Authored on Sep 27 2022, 11:45 PM
GitHub <noreply@github.com>Committed on Sep 27 2022, 11:45 PM
Parents
rG31b4e008f13f: LUA: Fix CVE-2014-5461
Branches
Unknown
Tags
Unknown

Event Timeline

GitHub <noreply@github.com> committed rG88b199c24e78: Cleanup spa_export_common() (authored by Richard Yao <richard.yao@alumni.stonybrook.edu>).Sep 27 2022, 11:45 PM