loader: zfs_fmtdev can crash when pool discovery did fail and we have no spa
When zfs probe did fail and no spa was created, but zfs_fmtdev() is called, we will crash while dereferencing spa (NULL pointer dereference). MFC after: 1 week
This commit is contained in:
parent
01a69565d8
commit
6b74887f03
@ -769,11 +769,16 @@ zfs_fmtdev(void *vdev)
|
||||
if (dev->dd.d_dev->dv_type != DEVT_ZFS)
|
||||
return (buf);
|
||||
|
||||
if (dev->pool_guid == 0) {
|
||||
spa = STAILQ_FIRST(&zfs_pools);
|
||||
/* Do we have any pools? */
|
||||
spa = STAILQ_FIRST(&zfs_pools);
|
||||
if (spa == NULL)
|
||||
return (buf);
|
||||
|
||||
if (dev->pool_guid == 0)
|
||||
dev->pool_guid = spa->spa_guid;
|
||||
} else
|
||||
else
|
||||
spa = spa_find_by_guid(dev->pool_guid);
|
||||
|
||||
if (spa == NULL) {
|
||||
printf("ZFS: can't find pool by guid\n");
|
||||
return (buf);
|
||||
|
Loading…
Reference in New Issue
Block a user