From: Jonathan Corbet <corbet@lwn.net>
To: 3237174131@qq.com, linux-kernel@vger.kernel.org
Cc: tglx@kernel.org, gregkh@linuxfoundation.org
Subject: Re: [PATCH] scripts/spdxcheck: fix file descriptor leak in read_spdxdata()
Date: Wed, 26 Aug 2026 10:42:28 -0600 [thread overview]
Message-ID: <8733w0suiz.fsf@trenco.lwn.net> (raw)
In-Reply-To: <tencent_0D1CF77320A0C199EB46300A4E82DADEA209@qq.com>
3237174131@qq.com writes:
> Hi all,
>
> This is my first kernel patch. Please let me know if anything is wrong.
Sending the patch as an attachment and the lack of a useful changelog
are both problems; please see
Documentation/process/submitting-patches.rst for information on how to
do this properly.
But, beyond that:
> Signed-off-by: Xia Zhoxin <3237174131@qq.com>
> From: Xia Zhoxin <3237174131@qq.com>
> Subject: [PATCH] scripts/spdxcheck: fix file descriptor leak in read_spdxdata()
> To: linux-kernel@vger.kernel.org
> Cc: tglx@kernel.org, gregkh@linuxfoundation.org
>
> Hi all,
>
> This is my first kernel patch. Please let me know if anything is wrong.
>
> Signed-off-by: Xia Zhoxin <3237174131@qq.com>
> ---
> 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:'):
open() returns a file object (*not* a file descriptor) that will
immediately go to a reference count of zero once .readlines() completes.
Garbage collection will then clean it up. So there is no actual leak
here.
Thanks,
jon
next prev parent reply other threads:[~2026-08-26 16:42 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-26 14:53 3237174131
2026-08-26 15:30 ` Greg KH
2026-08-26 16:42 ` Jonathan Corbet [this message]
-- strict thread matches above, loose matches on Subject: below --
2026-08-25 13:46 夏 周鑫
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=8733w0suiz.fsf@trenco.lwn.net \
--to=corbet@lwn.net \
--cc=3237174131@qq.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=tglx@kernel.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
all inboxes | Powered by JetHome®