* [LTP] [PATCH] hugemmap10: Treat fd 0 as valid in cleanup
@ 2026-09-29 11:15 Huaisheng Ye
2026-09-29 17:48 ` [LTP] " linuxtestproject.agent
2026-10-08 9:49 ` [LTP] [PATCH] " Li Wang
0 siblings, 2 replies; 3+ messages in thread
From: Huaisheng Ye @ 2026-09-29 11:15 UTC (permalink / raw)
To: li.wang, chrubis, pvorel; +Cc: ltp, LTP review agent
File descriptor 0 is valid when stdin is closed. The check in
per_iteration_cleanup() skips it and leaks the hugetlbfs file.
Initialize both map_fd slots to -1 and close any descriptor other than
-1. Initializing the slots also prevents cleanup from closing an unused
slot, which would otherwise start at zero.
Reported-by: LTP review agent <linuxtestproject.agent@gmail.com>
Signed-off-by: Huaisheng Ye <yehuaisheng@open-hieco.net>
---
testcases/kernel/mem/hugetlb/hugemmap/hugemmap10.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/testcases/kernel/mem/hugetlb/hugemmap/hugemmap10.c b/testcases/kernel/mem/hugetlb/hugemmap/hugemmap10.c
index bbbdc82ae..0ffd68962 100644
--- a/testcases/kernel/mem/hugetlb/hugemmap/hugemmap10.c
+++ b/testcases/kernel/mem/hugetlb/hugemmap/hugemmap10.c
@@ -37,7 +37,7 @@ static char *private_noreserve_opt;
#define NR_SLOTS 2
#define SL_SETUP 0
#define SL_TEST 1
-static int map_fd[NR_SLOTS];
+static int map_fd[NR_SLOTS] = { -1, -1 };
static char *map_addr[NR_SLOTS];
static unsigned long map_size[NR_SLOTS];
static unsigned int touched[NR_SLOTS];
@@ -494,7 +494,7 @@ static void per_iteration_cleanup(void)
for (nr = 0; nr < NR_SLOTS; nr++) {
if (map_addr[nr])
SAFE_MUNMAP(map_addr[nr], map_size[nr]);
- if (map_fd[nr] > 0)
+ if (map_fd[nr] != -1)
SAFE_CLOSE(map_fd[nr]);
}
}
--
2.52.0
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [LTP] hugemmap10: Treat fd 0 as valid in cleanup
2026-09-29 11:15 [LTP] [PATCH] hugemmap10: Treat fd 0 as valid in cleanup Huaisheng Ye
@ 2026-09-29 17:48 ` linuxtestproject.agent
2026-10-08 9:49 ` [LTP] [PATCH] " Li Wang
1 sibling, 0 replies; 3+ messages in thread
From: linuxtestproject.agent @ 2026-09-29 17:48 UTC (permalink / raw)
To: Huaisheng Ye; +Cc: ltp
Hi Huaisheng,
On Tue, 29 Sep 2026 19:15:27 +0800, Huaisheng Ye wrote:
> hugemmap10: Treat fd 0 as valid in cleanup
Verdict - Reviewed
---
Note:
The agent can sometimes produce false positives although often its
findings are genuine. If you find issues with the review, please
comment this email or ignore the suggestions.
Regards,
LTP AI Reviewer
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [LTP] [PATCH] hugemmap10: Treat fd 0 as valid in cleanup
2026-09-29 11:15 [LTP] [PATCH] hugemmap10: Treat fd 0 as valid in cleanup Huaisheng Ye
2026-09-29 17:48 ` [LTP] " linuxtestproject.agent
@ 2026-10-08 9:49 ` Li Wang
1 sibling, 0 replies; 3+ messages in thread
From: Li Wang @ 2026-10-08 9:49 UTC (permalink / raw)
To: Huaisheng Ye; +Cc: ltp, LTP review agent
This patch merged, thanks!
--
Regards,
Li Wang
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-10-08 9:49 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-29 11:15 [LTP] [PATCH] hugemmap10: Treat fd 0 as valid in cleanup Huaisheng Ye
2026-09-29 17:48 ` [LTP] " linuxtestproject.agent
2026-10-08 9:49 ` [LTP] [PATCH] " Li Wang
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.