From a7304ab9c1ea62c556aa7d007821322afc75ff79 Mon Sep 17 00:00:00 2001 From: Antonio Russo Date: Fri, 6 Jan 2023 11:52:08 -0700 Subject: [PATCH] ZTS: close in mmapwrite.c mmapwrite is used during the ZTS to identify issues with mmap-ed files. This helper program exercises this pathway by continuously writing to a file. ee6bf97c7 modified the writing threads to terminate after a set amount of total data is written. This change allows standard program execution to reach the end of a writer thread without closing the file descriptor, introducing a resource "leak." This patch appeases resource leak analyses by close()-ing the file at the end of the thread. Reviewed-by: Richard Yao Reviewed-by: Brian Behlendorf Signed-off-by: Antonio Russo Closes #14353 --- tests/zfs-tests/cmd/mmapwrite.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/zfs-tests/cmd/mmapwrite.c b/tests/zfs-tests/cmd/mmapwrite.c index 0a57daff5..20a50085a 100644 --- a/tests/zfs-tests/cmd/mmapwrite.c +++ b/tests/zfs-tests/cmd/mmapwrite.c @@ -82,6 +82,10 @@ normal_writer(void *filename) break; } } + + if (close(fd) != 0) + err(1, "failed to close file"); + return (NULL); }