FreeBSD: Fix potential boot panic with bad label

vdev_geom_read_pool_label() can leave NULL in configs.  Check for it
and skip consistently when generating rootconf.

Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Signed-off-by: Ryan Moeller <ryan@iXsystems.com>
Closes #14291
(cherry picked from commit dc8c2f6158)
This commit is contained in:
Ryan Moeller 2022-12-22 14:50:09 -05:00 committed by Brian Behlendorf
parent e84a2ed7a8
commit fbbc375d43
1 changed files with 2 additions and 0 deletions

View File

@ -95,6 +95,8 @@ spa_generate_rootconf(const char *name)
for (i = 0; i < count; i++) { for (i = 0; i < count; i++) {
uint64_t txg; uint64_t txg;
if (configs[i] == NULL)
continue;
txg = fnvlist_lookup_uint64(configs[i], ZPOOL_CONFIG_POOL_TXG); txg = fnvlist_lookup_uint64(configs[i], ZPOOL_CONFIG_POOL_TXG);
if (txg > best_txg) { if (txg > best_txg) {
best_txg = txg; best_txg = txg;