summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorTamir Duberstein <tamird@kernel.org>2026-01-27 11:35:43 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2026-04-22 13:32:18 +0200
commitb9bbd4d2f499a6d5562c842bc36328a1df2fe6c5 (patch)
tree859037cac97c2da54b9283e1e22472c74c8d0ed0 /scripts
parent0751a6aadebf8a6ad2719032fafc4a253dccb8c5 (diff)
scripts: generate_rust_analyzer.py: avoid FD leak
commit 9b4744d8eda2824041064a5639ccbb079850914d upstream. Use `pathlib.Path.read_text()` to avoid leaking file descriptors. Fixes: 8c4555ccc55c ("scripts: add `generate_rust_analyzer.py`") Cc: stable@vger.kernel.org Reviewed-by: Daniel Almeida <daniel.almeida@collabora.com> Reviewed-by: Fiona Behrens <me@kloenk.dev> Reviewed-by: Trevor Gross <tmgross@umich.edu> Link: https://patch.msgid.link/20260127-rust-analyzer-fd-leak-v2-1-1bb55b9b6822@kernel.org Signed-off-by: Tamir Duberstein <tamird@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/generate_rust_analyzer.py3
1 files changed, 2 insertions, 1 deletions
diff --git a/scripts/generate_rust_analyzer.py b/scripts/generate_rust_analyzer.py
index f9b545104f21..bd42f06bb8ed 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()
except FileNotFoundError:
return False
+ return f"{target}.o" in contents
# Then, the rest outside of `rust/`.
#