Re: [PATCH] selftests: memcg: don't close an uninitialized fd

From: Shakeel Butt

Date: Mon Oct 12 2026 - 14:17:17 EST


On Sun, Oct 11, 2026 at 06:33:37PM -0400, Sasha Levin wrote:
> test_memcg_inotify_delete_file() and test_memcg_inotify_delete_dir()
> jump to cleanup before the inotify fd is created when cg_name() or
> cg_create() fails, and cleanup then closes whatever fd holds:
>
> test_memcontrol.c:1685:6: warning: variable 'fd' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
>
> Initialize fd to -1.
>
> Fixes: 2de27980e1d46 ("selftests: memcg: Add tests for IN_DELETE_SELF and IN_IGNORED")
> Assisted-by: LLM
> Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

Acked-by: Shakeel Butt <shakeel.butt@xxxxxxxxx>