From: Paul Moore <paul@paul-moore.com>
To: Wang Yan <wangyan01@kylinos.cn>, bill.c.roberts@gmail.com
Cc: casey@schaufler-ca.com, jmorris@namei.org,
linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org,
linux-security-module@vger.kernel.org, mic@digikod.net,
serge@hallyn.com, shuah@kernel.org, wangyan01@kylinos.cn
Subject: Re: [PATCH v2] selftests/lsm: Fix memory leak in attr_lsm_count
Date: Tue, 07 Jul 2026 15:13:58 -0400 [thread overview]
Message-ID: <14023e3368d98072f369e6fe1607c7d5@paul-moore.com> (raw)
In-Reply-To: <20260703120951.1622491-1-wangyan01@kylinos.cn>
On Jul 3, 2026 Wang Yan <wangyan01@kylinos.cn> wrote:
>
> The calloc-allocated buffer in attr_lsm_count() is never released on
> any exit path, including both the normal return path and the early
> return when read_sysfs_lsms fails, resulting in a heap memory leak.
>
> Add free() for the buffer on all return branches to fix the leak.
>
> Fixes: d3d929a8b0cd ("LSM: selftests for Linux Security Module syscalls")
> Signed-off-by: Wang Yan <wangyan01@kylinos.cn>
> Reviewed-by: William Roberts <bill.c.roberts@gmail.com>
> Tested-by: William Roberts <bill.c.roberts@gmail.com>
> ---
> tools/testing/selftests/lsm/common.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
Merged into lsm/dev, thanks!
--
paul-moore.com
prev parent reply other threads:[~2026-07-07 19:14 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-03 2:52 [PATCH] selftests/lsm: Fix memory leak in attr_lsm_count Wang Yan
2026-07-03 3:01 ` William Roberts
2026-07-03 12:09 ` [PATCH v2] " Wang Yan
2026-07-03 17:56 ` William Roberts
2026-07-07 19:13 ` Paul Moore [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=14023e3368d98072f369e6fe1607c7d5@paul-moore.com \
--to=paul@paul-moore.com \
--cc=bill.c.roberts@gmail.com \
--cc=casey@schaufler-ca.com \
--cc=jmorris@namei.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=linux-security-module@vger.kernel.org \
--cc=mic@digikod.net \
--cc=serge@hallyn.com \
--cc=shuah@kernel.org \
--cc=wangyan01@kylinos.cn \
/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