From 729a0f2e0c59b342292ceb47fbc014f00c409524 Mon Sep 17 00:00:00 2001 From: Robert Millan Date: Sun, 15 Aug 2010 22:48:23 +0200 Subject: [PATCH] 2010-08-15 Robert Millan * kern/emu/misc.c (grub_get_libzfs_handle): Handle libzfs_init() errors. * kern/emu/getroot.c (find_root_device_from_libzfs): Handle grub_get_libzfs_handle() errors. --- ChangeLog | 7 +++++++ kern/emu/getroot.c | 7 ++++++- kern/emu/misc.c | 4 +++- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index b88eae46f..b662428bc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2010-08-15 Robert Millan + + * kern/emu/misc.c (grub_get_libzfs_handle): Handle libzfs_init() + errors. + * kern/emu/getroot.c (find_root_device_from_libzfs): Handle + grub_get_libzfs_handle() errors. + 2010-08-14 Robert Millan * kern/emu/misc.c (grub_find_zpool_from_dir): Abort function if diff --git a/kern/emu/getroot.c b/kern/emu/getroot.c index 321b33bb3..c0a10d22b 100644 --- a/kern/emu/getroot.c +++ b/kern/emu/getroot.c @@ -188,11 +188,16 @@ find_root_device_from_libzfs (const char *dir) { zpool_handle_t *zpool; + libzfs_handle_t *libzfs; nvlist_t *nvlist; nvlist_t **nvlist_array; unsigned int nvlist_count; - zpool = zpool_open (grub_get_libzfs_handle (), poolname); + libzfs = grub_get_libzfs_handle (); + if (! libzfs) + return NULL; + + zpool = zpool_open (libzfs, poolname); nvlist = zpool_get_config (zpool, NULL); if (nvlist_lookup_nvlist (nvlist, "vdev_tree", &nvlist) != 0) diff --git a/kern/emu/misc.c b/kern/emu/misc.c index 29be87720..82f579616 100644 --- a/kern/emu/misc.c +++ b/kern/emu/misc.c @@ -268,7 +268,9 @@ grub_get_libzfs_handle (void) if (! __libzfs_handle) { __libzfs_handle = libzfs_init (); - atexit (fini_libzfs); + + if (__libzfs_handle) + atexit (fini_libzfs); } return __libzfs_handle;