On Sat,  4 Jul 2026 17:34:36 +0530 Malaya Kumar Rout <[email protected]> 
wrote:

> In setup_namespace(), f_mountinfo is opened with fopen() at line 115
> but is never closed. Multiple ksft_exit_fail_msg() calls exit the
> program without closing this file descriptor, and the cleanup_namespace()
> function registered with atexit() also doesn't close it.
> 
> Add fclose(f_mountinfo) in cleanup_namespace() to ensure the file
> descriptor is properly closed on both normal and error exit paths,
> since cleanup_namespace() is already registered as an atexit handler.
> 

Thanks.

get_maintainer totally sucks with selftests/, alas.  When determining
who should be cc'ed it's best to poke around in git-blame.

I did that.  Hi, Miklos!


> --- a/tools/testing/selftests/filesystems/statmount/statmount_test.c
> +++ b/tools/testing/selftests/filesystems/statmount/statmount_test.c
> @@ -82,6 +82,9 @@ static void cleanup_namespace(void)
>  {
>       int ret;
>  
> +     if (f_mountinfo)
> +             fclose(f_mountinfo);
> +
>       ret = fchdir(orig_root);
>       if (ret == -1)
>               ksft_perror("fchdir to original root");

AI review suggests that the patch is good, but the leak is not fully
resolved:

        
https://sashiko.dev/#/patchset/[email protected]



All that being said, we don't care much about leaks in selftests/. 
Because exit() handles them pretty darn well.  So fixing this is mainly
a matter of pride and of setting a good example.



Reply via email to