Re: [PATCH v2] selftests/lsm: Fix memory leak in attr_lsm_count
From: Paul Moore
Date: Tue Jul 07 2026 - 15:14:54 EST
On Jul 3, 2026 Wang Yan <wangyan01@xxxxxxxxxx> 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@xxxxxxxxxx>
> Reviewed-by: William Roberts <bill.c.roberts@xxxxxxxxx>
> Tested-by: William Roberts <bill.c.roberts@xxxxxxxxx>
> ---
> tools/testing/selftests/lsm/common.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
Merged into lsm/dev, thanks!
--
paul-moore.com