From 5dc6fc2b73bffd9876374260e7840cc1177bf726 Mon Sep 17 00:00:00 2001 From: Rich Ercolani <214141+rincebrain@users.noreply.github.com> Date: Tue, 30 Nov 2021 13:36:36 -0500 Subject: [PATCH] Stop segfaulting on unmount error case After interrupting ZTS runs that errored out, I found that "zpool export testpool2" was segfaulting. This seems unnecessary. Reviewed-by: szubersk Reviewed-by: Brian Behlendorf Reviewed-by: Jorgen Lundman Signed-off-by: Rich Ercolani Closes #12804 --- lib/libzfs/libzfs_mount.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/libzfs/libzfs_mount.c b/lib/libzfs/libzfs_mount.c index b0279d8fbc..e97de8f202 100644 --- a/lib/libzfs/libzfs_mount.c +++ b/lib/libzfs/libzfs_mount.c @@ -595,9 +595,13 @@ unmount_one(zfs_handle_t *zhp, const char *mountpoint, int flags) default: libzfs_err = EZFS_UMOUNTFAILED; } - return (zfs_error_fmt(zhp->zfs_hdl, libzfs_err, - dgettext(TEXT_DOMAIN, "cannot unmount '%s'"), - mountpoint)); + if (zhp) { + return (zfs_error_fmt(zhp->zfs_hdl, libzfs_err, + dgettext(TEXT_DOMAIN, "cannot unmount '%s'"), + mountpoint)); + } else { + return (-1); + } } return (0);