[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAJ-ks9=hKVVa9UXFXx-aiqba7U0UHQChf-5pf1d=TdYrtC11Yw@mail.gmail.com>
Date: Tue, 27 Jan 2026 11:46:44 -0500
From: Tamir Duberstein <tamird@...nel.org>
To: Gary Guo <gary@...yguo.net>
Cc: Miguel Ojeda <ojeda@...nel.org>, Boqun Feng <boqun.feng@...il.com>,
Björn Roy Baron <bjorn3_gh@...tonmail.com>,
Benno Lossin <lossin@...nel.org>, Andreas Hindborg <a.hindborg@...nel.org>,
Alice Ryhl <aliceryhl@...gle.com>, Trevor Gross <tmgross@...ch.edu>,
Danilo Krummrich <dakr@...nel.org>, Alex Gaynor <alex.gaynor@...il.com>, Fiona Behrens <me@...enk.dev>,
Boris-Chengbiao Zhou <bobo1239@....de>, Kees Cook <kees@...nel.org>, rust-for-linux@...r.kernel.org,
linux-kernel@...r.kernel.org, stable@...r.kernel.org,
Daniel Almeida <daniel.almeida@...labora.com>
Subject: Re: [PATCH v2] scripts: generate_rust_analyzer.py: avoid FD leak
On Tue, Jan 27, 2026 at 11:41 AM Gary Guo <gary@...yguo.net> wrote:
>
> On Tue Jan 27, 2026 at 4:35 PM GMT, Tamir Duberstein wrote:
> > Use `pathlib.Path.read_text()` to avoid leaking file descriptors.
> >
> > Fixes: 8c4555ccc55c ("scripts: add `generate_rust_analyzer.py`")
> > Cc: stable@...r.kernel.org
> > Reviewed-by: Daniel Almeida <daniel.almeida@...labora.com>
> > Reviewed-by: Fiona Behrens <me@...enk.dev>
> > Reviewed-by: Trevor Gross <tmgross@...ch.edu>
> > Signed-off-by: Tamir Duberstein <tamird@...nel.org>
> > ---
> > Changes in v2:
> > - Use pathlib.Path.read_text. (Levi Zim)
> > - Drop errant Tested-by tag. (Miguel Ojeda)
> > - Link to v1: https://patch.msgid.link/20260122-rust-analyzer-fd-leak-v1-1-945577813b20@kernel.org
> > ---
> > scripts/generate_rust_analyzer.py | 3 ++-
> > 1 file changed, 2 insertions(+), 1 deletion(-)
> >
> > diff --git a/scripts/generate_rust_analyzer.py b/scripts/generate_rust_analyzer.py
> > index 3b645da90092..152bd3705303 100755
> > --- a/scripts/generate_rust_analyzer.py
> > +++ b/scripts/generate_rust_analyzer.py
> > @@ -190,9 +190,10 @@ def generate_crates(srctree, objtree, sysroot_src, external_src, cfgs, core_edit
> >
> > def is_root_crate(build_file, target):
> > try:
> > - return f"{target}.o" in open(build_file).read()
> > + contents = build_file.read_text()
>
> Couldn't this just be
>
> return f"{target.o}" in build_file.read_text()
>
> ?
Yes, of course. I chose this form to be just a bit more explicit about
exception handling.
Powered by blists - more mailing lists