From ff524b2355c0ac08bf963297ae8e5ea2e8375852 Mon Sep 17 00:00:00 2001 From: Andrew Stormont Date: Sun, 12 Feb 2017 00:33:35 +0000 Subject: [PATCH] 7857 zfs/zpool commands print scary errors after 7741 7887 get_zfs_dataset() optimised path leaks zfs handle Reviewed by: Sam Zaydel Reviewed by: Matthew Ahrens Approved by: Richard Lowe --- usr/src/lib/libshare/common/libshare_zfs.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/usr/src/lib/libshare/common/libshare_zfs.c b/usr/src/lib/libshare/common/libshare_zfs.c index ec465295b1..08b5a00e9d 100644 --- a/usr/src/lib/libshare/common/libshare_zfs.c +++ b/usr/src/lib/libshare/common/libshare_zfs.c @@ -25,6 +25,7 @@ /* * Copyright 2012 Nexenta Systems, Inc. All rights reserved. * Copyright (c) 2012, 2016 by Delphix. All rights reserved. + * Copyright 2017 RackTop Systems. */ #include @@ -336,11 +337,20 @@ get_zfs_dataset(sa_handle_impl_t impl_handle, char *path, cutpath = path + strspn(path, "/"); assert(impl_handle->zfs_libhandle != NULL); + libzfs_print_on_error(impl_handle->zfs_libhandle, B_FALSE); if ((handle_from_path = zfs_open(impl_handle->zfs_libhandle, cutpath, - ZFS_TYPE_FILESYSTEM)) != NULL) + ZFS_TYPE_FILESYSTEM)) != NULL) { if ((ret = verify_zfs_handle(handle_from_path, path, - search_mnttab)) != NULL) + search_mnttab)) != NULL) { + zfs_close(handle_from_path); + libzfs_print_on_error(impl_handle->zfs_libhandle, + B_TRUE); return (ret); + } + zfs_close(handle_from_path); + } + libzfs_print_on_error(impl_handle->zfs_libhandle, B_TRUE); + /* * Couldn't find a filesystem optimistically, check all the handles we * can. -- 2.11.4.GIT