[PATCH] scripts/spdxcheck: fix file descriptor leak in read_spdxdata()
From: 夏 周鑫
Date: Tue Aug 25 2026 - 09:50:24 EST
Hi all,
This is my first kernel patch. Please let me know if anything is wrong.
Signed-off-by: Xia Zhoxin <x15726828610@xxxxxxxxxxx>
---
scripts/spdxcheck.py | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/scripts/spdxcheck.py b/scripts/spdxcheck.py
--- a/scripts/spdxcheck.py
+++ b/scripts/spdxcheck.py
@@ -72,7 +72,8 @@ def read_spdxdata(repo):
exception = None
- for l in open(el.path, encoding="utf-8").readlines():
+ with open(el.path, encoding="utf-8") as f:
+ for l in f:
if l.startswith('Valid-License-Identifier:'):
lid = l.split(':')[1].strip().upper()
if lid in spdx.licenses: