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

Andrea Cervesato andrea.cervesato@suse.de
Fri Jul 17 14:33:19 CEST 2026


From: Andrea Cervesato <andrea.cervesato@suse.com>

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 <andrea.cervesato@suse.com>
---
 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



More information about the ltp mailing list