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

Andrea Cervesato <[email protected]>
Newsgroups gmane.linux.ltp
Message-ID <[email protected]>
From: Andrea Cervesato <andrea.cervesato-IBi9RG/[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 <andrea.cervesato-IBi9RG/[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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.