From 5371d8dae7855738dae62d414b121aedc3541a9a Mon Sep 17 00:00:00 2001 From: Antonio Russo <aerusso@aerusso.net> Date: Fri, 6 Jan 2023 11:52:08 -0700 Subject: [PATCH] ZTS: close in mmapwrite.c commit a7304ab9c1ea62c556aa7d007821322afc75ff79 upstream 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 <richard.yao@alumni.stonybrook.edu> Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Antonio Russo <aerusso@aerusso.net> Closes #14353 --- tests/zfs-tests/cmd/mmapwrite/mmapwrite.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/zfs-tests/cmd/mmapwrite/mmapwrite.c b/tests/zfs-tests/cmd/mmapwrite/mmapwrite.c index baf9788ed..438cba369 100644 --- a/tests/zfs-tests/cmd/mmapwrite/mmapwrite.c +++ b/tests/zfs-tests/cmd/mmapwrite/mmapwrite.c @@ -86,6 +86,10 @@ normal_writer(void *filename) if (buf) { free(buf); } + + if (close(fd) != 0) + err(1, "failed to close file"); + return (NULL); }