Re: [PATCH] selftests/cgroup: free the paths returned by cg_control()
From: Michal Koutný
Date: Mon Oct 12 2026 - 08:45:46 EST
On Sun, Oct 11, 2026 at 06:33:38PM -0400, Sasha Levin <sashal@xxxxxxxxxx> wrote:
> cg_control() returns a path allocated with malloc(). The two callers
> that pass it straight to inotify_add_watch() never free it, and pass
> NULL to it if the allocation fails.
>
> Keep the path in a local variable, check it, and free it when done.
>
> Fixes: 5313bfe425c8a ("kselftests: cgroup: add freezer controller self-tests")
> Fixes: 2de27980e1d46 ("selftests: memcg: Add tests for IN_DELETE_SELF and IN_IGNORED")
> Assisted-by: LLM
> Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>
> ---
> tools/testing/selftests/cgroup/lib/cgroup_util.c | 13 ++++++++++---
> tools/testing/selftests/cgroup/test_memcontrol.c | 9 +++++++--
> 2 files changed, 17 insertions(+), 5 deletions(-)
Thanks,
Acked-by: Michal Koutný <mkoutny@xxxxxxxx>
Attachment:
signature.asc
Description: PGP signature