From 7d97e1ce152daa4d7c565aa632ccc55d0074fe66 Mon Sep 17 00:00:00 2001 From: Anoop C S Date: Mon, 12 Oct 2020 16:55:40 +0530 Subject: [PATCH] vfs_shadow_copy2: Avoid closing snapsdir twice MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit As per man page for closedir(3): . . . The closedir() function closes the directory stream associated with dirp. A successful call to closedir() also closes the underlying file descriptor associated with dirp. . . . Therefore we don't have to attempt an additional close of file descriptor after closedir(). BUG: https://bugzilla.samba.org/show_bug.cgi?id=14530 Signed-off-by: Jeremy Allison Signed-off-by: Anoop C S Reviewed-by: Ralph Boehme Autobuild-User(master): Ralph Böhme Autobuild-Date(master): Wed Oct 14 10:08:24 UTC 2020 on sn-devel-184 (cherry picked from commit 74fbe0b987a0333cca28bb6a547e5b4b4f2e706d) --- source3/modules/vfs_shadow_copy2.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/source3/modules/vfs_shadow_copy2.c b/source3/modules/vfs_shadow_copy2.c index 3be93f985dd..8ccc4dd77ec 100644 --- a/source3/modules/vfs_shadow_copy2.c +++ b/source3/modules/vfs_shadow_copy2.c @@ -2116,6 +2116,13 @@ done: if (p != NULL) { SMB_VFS_NEXT_CLOSEDIR(handle, p); p = NULL; + if (dirfsp != NULL) { + /* + * VFS_CLOSEDIR implicitly + * closed the associated fd. + */ + dirfsp->fh->fd = -1; + } } if (dirfsp != NULL) { fd_close(dirfsp); -- 2.26.2