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

Petr Vorel <[email protected]> Tue, 28 Jul 2026 16:00:25 +0200
Newsgroups it.linux.lists.ltp
Message-ID <20260728140025.GC1128467@pevik>
Hi Andrea,

> 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);
Good catch!
Reviewed-by: Petr Vorel <[email protected]>

Kind regards,
Petr
>  			return;
>  		}

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