From 55a381515bf2a78ddc7994c4fef4204148254b3f Mon Sep 17 00:00:00 2001 From: Martin Matuska Date: Sun, 23 May 2010 10:13:11 +0000 Subject: [PATCH] Fix kernel panic when calling spa_tryimport() on a corrupted pool. OpenSolaris onnv revision: 8680:005fe27123ba Approved by: delphij (mentor) Obtained from: OpenSolaris (Bug ID 6786321) MFC after: 1 day --- sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c index 80a35bcbf1c6..527981f67b73 100644 --- a/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c +++ b/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/spa.c @@ -2478,6 +2478,7 @@ spa_tryimport(nvlist_t *tryconfig) char *poolname; spa_t *spa; uint64_t state; + int error; if (nvlist_lookup_string(tryconfig, ZPOOL_CONFIG_POOL_NAME, &poolname)) return (NULL); @@ -2497,7 +2498,7 @@ spa_tryimport(nvlist_t *tryconfig) * Pass TRUE for mosconfig because the user-supplied config * is actually the one to trust when doing an import. */ - (void) spa_load(spa, tryconfig, SPA_LOAD_TRYIMPORT, B_TRUE); + error = spa_load(spa, tryconfig, SPA_LOAD_TRYIMPORT, B_TRUE); /* * If 'tryconfig' was at least parsable, return the current config. @@ -2516,7 +2517,7 @@ spa_tryimport(nvlist_t *tryconfig) * copy it out so that external consumers can tell which * pools are bootable. */ - if (spa->spa_bootfs) { + if ((!error || error == EEXIST) && spa->spa_bootfs) { char *tmpname = kmem_alloc(MAXPATHLEN, KM_SLEEP); /*