From: Sowrabha Gopal Date: Thu, 1 Jun 2017 20:27:02 +0000 (-0700) Subject: OpenZFS 8430 - dir_is_empty_readdir() doesn't properly handle error from fdopendir() X-Git-Tag: zfs-0.7.0-rc5~26 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=aa6e82a6a55d6fde7a8dc1c21bf952df69ef9a20;p=zfs 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 --- 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); }