From 2506e819662fc47fdbf6bb44b5111de80468b466 Mon Sep 17 00:00:00 2001 From: Antonio Russo Date: Thu, 5 Jan 2023 19:31:37 -0700 Subject: [PATCH] [ZTS] fclose 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 fclose()-ing the file at the end of the thread. Signed-off-by: Antonio Russo --- 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 0a57daff5eae..20a50085a227 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); }