From aa6e82a6a55d6fde7a8dc1c21bf952df69ef9a20 Mon Sep 17 00:00:00 2001 From: Sowrabha Gopal Date: Thu, 1 Jun 2017 13:27:02 -0700 Subject: [PATCH] OpenZFS 8430 - dir_is_empty_readdir() doesn't properly handle error from fdopendir() Authored by: Sowrabha Gopal Reviewed by: Serapheim Dimitropoulos Reviewed by: Matthew Ahrens Reviewed by: Dan Kimmel Reviewed by: Yuri Pankov Reviewed by: Igor Kozhukhov Approved by: Robert Mustacchi Reviewed-by: Brian Behlendorf Reviewed-by: George Melikov Ported-by: Giuseppe Di Natale dir_is_empty_readdir() immediately returns if fdopendir() fails. We should close dirfd when that happens. OpenZFS-issue: https://www.illumos.org/issues/8430 OpenZFS-commit: https://github.com/openzfs/openzfs/commit/e165e20 Closes #6289 --- lib/libzfs/libzfs_mount.c | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/libzfs/libzfs_mount.c b/lib/libzfs/libzfs_mount.c index 6296eb13a..a66278627 100644 --- a/lib/libzfs/libzfs_mount.c +++ b/lib/libzfs/libzfs_mount.c @@ -210,6 +210,7 @@ dir_is_empty_readdir(const char *dirname) } if ((dirp = fdopendir(dirfd)) == NULL) { + (void) close(dirfd); return (B_TRUE); } -- 2.40.0