linux/tools/testing/selftests/lsm
Wang Yan 0cee720cfd selftests/lsm: Fix memory leak in attr_lsm_count
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: d3d929a8b0 ("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>
Signed-off-by: Paul Moore <paul@paul-moore.com>
2026-07-07 15:14:00 -04:00
..
.gitignore LSM: selftests for Linux Security Module syscalls 2023-11-12 22:54:42 -05:00
common.c selftests/lsm: Fix memory leak in attr_lsm_count 2026-07-07 15:14:00 -04:00
common.h lsm: use 32-bit compatible data types in LSM syscalls 2024-03-14 11:31:26 -04:00
config LSM: selftests for Linux Security Module syscalls 2023-11-12 22:54:42 -05:00
lsm_get_self_attr_test.c selftests: complete kselftest include centralization 2025-11-27 14:24:31 -08:00
lsm_list_modules_test.c selftests: complete kselftest include centralization 2025-11-27 14:24:31 -08:00
lsm_set_self_attr_test.c selftests: complete kselftest include centralization 2025-11-27 14:24:31 -08:00
Makefile LSM: selftests for Linux Security Module syscalls 2023-11-12 22:54:42 -05:00