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

Petr Vorel pvorel@suse.cz
Tue Jul 28 16:00:25 CEST 2026


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 <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);
Good catch!
Reviewed-by: Petr Vorel <pvorel@suse.cz>

Kind regards,
Petr
>  			return;
>  		}


More information about the ltp mailing list