svn commit: r353757 - head/stand/libsa/zfs
Toomas Soome
tsoome at FreeBSD.org
Sat Oct 19 08:08:07 UTC 2019
Author: tsoome
Date: Sat Oct 19 08:08:06 2019
New Revision: 353757
URL: https://svnweb.freebsd.org/changeset/base/353757
Log:
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
Modified:
head/stand/libsa/zfs/zfs.c
Modified: head/stand/libsa/zfs/zfs.c
==============================================================================
--- head/stand/libsa/zfs/zfs.c Sat Oct 19 07:53:20 2019 (r353756)
+++ head/stand/libsa/zfs/zfs.c Sat Oct 19 08:08:06 2019 (r353757)
@@ -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);
More information about the svn-src-head
mailing list