[LTP] [PATCH 2/3] lib: Close directory fd on ENOSPC in tst_fill_fs

Andrea Cervesato <[email protected]> Fri, 17 Jul 2026 14:33:19 +0200
Newsgroups it.linux.lists.ltp
Message-ID <[email protected]>
From: Andrea Cervesato <[email protected]>

The directory descriptor opened at the top of the function was leaked
when openat() failed with ENOSPC and the function returned early. Close
it before returning.

Signed-off-by: Andrea Cervesato <[email protected]>
---
 lib/tst_fill_fs.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lib/tst_fill_fs.c b/lib/tst_fill_fs.c
index c62d48e289965d59ef6c877870c6047bbecb33da..b1e48fdeea6ab00848aab482fd3899fc6f6ce23c 100644
--- a/lib/tst_fill_fs.c
+++ b/lib/tst_fill_fs.c
@@ -91,6 +91,7 @@ static void fill_flat_vec(const char *path, int verbose)
 	if (fd == -1) {
 		if (errno == ENOSPC) {
 			tst_res(TINFO | TERRNO, "openat()");
+			SAFE_CLOSE(dir);
 			return;
 		}
 		tst_brk(TBROK | TERRNO, "openat(%d, %d, 0600) failed for path %s",

-- 
2.51.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp