From: Andrew Morton <akpm@linux-foundation.org>
To: Malaya Kumar Rout <malayarout91@gmail.com>
Cc: linux-kselftest@vger.kernel.org, mrout@redhat.com,
skhan@linuxfoundation.org, me@brighamcampbell.com,
Shuah Khan <shuah@kernel.org>,
Christian Brauner <brauner@kernel.org>,
Andrei Vagin <avagin@gmail.com>,
Bala-Vignesh-Reddy <reddybalavignesh9979@gmail.com>,
Bhavik Sachdev <b.sachdev1904@gmail.com>,
linux-kernel@vger.kernel.org, Miklos Szeredi <miklos@szeredi.hu>
Subject: Re: [PATCH] selftests/statmount: Fix file descriptor leak in setup_namespace
Date: Wed, 2 Sep 2026 18:15:19 -0700 [thread overview]
Message-ID: <20260902181519.f99e0943d99dc06a1afd740d@linux-foundation.org> (raw)
In-Reply-To: <20260704120437.99851-1-malayarout91@gmail.com>
On Sat, 4 Jul 2026 17:34:36 +0530 Malaya Kumar Rout <malayarout91@gmail.com> 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/20260704120437.99851-1-malayarout91@gmail.com
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.
prev parent reply other threads:[~2026-09-03 1:15 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-04 12:04 [PATCH] selftests/statmount: Fix file descriptor leak in setup_namespace Malaya Kumar Rout
2026-07-06 13:08 ` Christian Brauner
2026-09-03 1:15 ` Andrew Morton [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260902181519.f99e0943d99dc06a1afd740d@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=avagin@gmail.com \
--cc=b.sachdev1904@gmail.com \
--cc=brauner@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=malayarout91@gmail.com \
--cc=me@brighamcampbell.com \
--cc=miklos@szeredi.hu \
--cc=mrout@redhat.com \
--cc=reddybalavignesh9979@gmail.com \
--cc=shuah@kernel.org \
--cc=skhan@linuxfoundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox