diff options
author | Richard Yao <[email protected]> | 2022-10-15 18:27:03 -0400 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2022-10-19 17:10:21 -0700 |
commit | 4ecd96371bcd71b4f0e3be3591098037a58977cb (patch) | |
tree | 95b1881ad10aa218e1b9a1aed0bc59152fdee461 | |
parent | 219cf0f928475d832d5a7bf0e286ee9ae008fb84 (diff) |
Fix theoretical use of uninitialized values
Clang's static analyzer complains about this.
In get_configs(), if we have an invalid configuration that has no top
level vdevs, we can read a couple of uninitialized variables. Aborting
upon seeing this would break the userland tools for healthy pools, so we
instead initialize the two variables to 0 to allow the userland tools to
continue functioning for the pools with valid configurations.
In zfs_do_wait(), if no wait activities are enabled, we read an
uninitialized error variable.
Reviewed-by: Brian Behlendorf <[email protected]>
Signed-off-by: Richard Yao <[email protected]>
Closes #14043
-rw-r--r-- | cmd/zfs/zfs_main.c | 2 | ||||
-rw-r--r-- | lib/libzutil/zutil_import.c | 5 |
2 files changed, 3 insertions, 4 deletions
diff --git a/cmd/zfs/zfs_main.c b/cmd/zfs/zfs_main.c index dddf387de..bdbd0bfc6 100644 --- a/cmd/zfs/zfs_main.c +++ b/cmd/zfs/zfs_main.c @@ -8554,7 +8554,7 @@ static int zfs_do_wait(int argc, char **argv) { boolean_t enabled[ZFS_WAIT_NUM_ACTIVITIES]; - int error, i; + int error = 0, i; int c; /* By default, wait for all types of activity. */ diff --git a/lib/libzutil/zutil_import.c b/lib/libzutil/zutil_import.c index e7a755dcb..fee176184 100644 --- a/lib/libzutil/zutil_import.c +++ b/lib/libzutil/zutil_import.c @@ -501,11 +501,9 @@ get_configs(libpc_handle_t *hdl, pool_list_t *pl, boolean_t active_ok, uint64_t guid; uint_t children = 0; nvlist_t **child = NULL; - uint_t holes; uint64_t *hole_array, max_id; uint_t c; boolean_t isactive; - uint64_t hostid; nvlist_t *nvl; boolean_t valid_top_config = B_FALSE; @@ -513,7 +511,8 @@ get_configs(libpc_handle_t *hdl, pool_list_t *pl, boolean_t active_ok, goto nomem; for (pe = pl->pools; pe != NULL; pe = pe->pe_next) { - uint64_t id, max_txg = 0; + uint64_t id, max_txg = 0, hostid = 0; + uint_t holes = 0; if (nvlist_alloc(&config, NV_UNIQUE_NAME, 0) != 0) goto nomem; |