Skip to content

Commit

Permalink
FreeBSD: Fix potential boot panic with bad label
Browse files Browse the repository at this point in the history
vdev_geom_read_pool_label() can leave NULL in configs.  Check for it
and skip consistently when generating rootconf.

Signed-off-by: Ryan Moeller <ryan@iXsystems.com>
  • Loading branch information
Ryan Moeller authored and Ryan Moeller committed Dec 15, 2022
1 parent 24502bd commit 14ef1c9
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions module/os/freebsd/zfs/spa_os.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,20 @@ spa_generate_rootconf(const char *name)
for (i = 0; i < count; i++) {
uint64_t txg;

if (configs[i] == NULL)
continue;
txg = fnvlist_lookup_uint64(configs[i], ZPOOL_CONFIG_POOL_TXG);
if (txg > best_txg) {
best_txg = txg;
best_cfg = configs[i];
}
}
if (best_cfg == NULL) {
for (i = 0; i < count; i++)
fnvlist_free(configs[i]);
kmem_free(configs, count * sizeof (void *));
return (NULL);
}

nchildren = 1;
nvlist_lookup_uint64(best_cfg, ZPOOL_CONFIG_VDEV_CHILDREN, &nchildren);
Expand Down

0 comments on commit 14ef1c9

Please sign in to comment.