All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] selftests: memcg: don't close an uninitialized fd
@ 2026-10-11 22:33 Sasha Levin
  2026-10-12 12:45 ` Michal Koutný
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Sasha Levin @ 2026-10-11 22:33 UTC (permalink / raw)
  To: Johannes Weiner, Michal Hocko, Roman Gushchin, Shakeel Butt,
	Muchun Song, Tejun Heo, Michal Koutný, Shuah Khan,
	Greg Kroah-Hartman, T.J. Mercier, Amir Goldstein
  Cc: Sasha Levin, cgroups, linux-mm, linux-kselftest, linux-kernel

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@kernel.org>
---
 tools/testing/selftests/cgroup/test_memcontrol.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/testing/selftests/cgroup/test_memcontrol.c b/tools/testing/selftests/cgroup/test_memcontrol.c
index 0ed82347044ed..047d487f6dd57 100644
--- a/tools/testing/selftests/cgroup/test_memcontrol.c
+++ b/tools/testing/selftests/cgroup/test_memcontrol.c
@@ -1678,7 +1678,7 @@ static int test_memcg_inotify_delete_file(const char *root)
 {
 	int ret = KSFT_FAIL;
 	char *memcg = NULL;
-	int fd, wd;
+	int fd = -1, wd;
 
 	memcg = cg_name(root, "memcg_test_0");
 
@@ -1723,7 +1723,7 @@ static int test_memcg_inotify_delete_dir(const char *root)
 {
 	int ret = KSFT_FAIL;
 	char *memcg = NULL;
-	int fd, wd;
+	int fd = -1, wd;
 
 	memcg = cg_name(root, "memcg_test_0");
 
-- 
2.53.0



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] selftests: memcg: don't close an uninitialized fd
  2026-10-11 22:33 [PATCH] selftests: memcg: don't close an uninitialized fd Sasha Levin
@ 2026-10-12 12:45 ` Michal Koutný
  2026-10-12 14:09 ` T.J. Mercier
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Michal Koutný @ 2026-10-12 12:45 UTC (permalink / raw)
  To: Sasha Levin
  Cc: Johannes Weiner, Michal Hocko, Roman Gushchin, Shakeel Butt,
	Muchun Song, Tejun Heo, Shuah Khan, Greg Kroah-Hartman,
	T.J. Mercier, Amir Goldstein, cgroups, linux-mm, linux-kselftest,
	linux-kernel

[-- Attachment #1: Type: text/plain, Size: 801 bytes --]

On Sun, Oct 11, 2026 at 06:33:37PM -0400, Sasha Levin <sashal@kernel.org> 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@kernel.org>
> ---
>  tools/testing/selftests/cgroup/test_memcontrol.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

Thanks too,
Acked-by: Michal Koutný <mkoutny@suse.com>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 265 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] selftests: memcg: don't close an uninitialized fd
  2026-10-11 22:33 [PATCH] selftests: memcg: don't close an uninitialized fd Sasha Levin
  2026-10-12 12:45 ` Michal Koutný
@ 2026-10-12 14:09 ` T.J. Mercier
  2026-10-12 17:08 ` Shakeel Butt
  2026-10-12 17:54 ` Tejun Heo
  3 siblings, 0 replies; 5+ messages in thread
From: T.J. Mercier @ 2026-10-12 14:09 UTC (permalink / raw)
  To: Sasha Levin
  Cc: Johannes Weiner, Michal Hocko, Roman Gushchin, Shakeel Butt,
	Muchun Song, Tejun Heo, Michal Koutný, Shuah Khan,
	Greg Kroah-Hartman, Amir Goldstein, cgroups, linux-mm,
	linux-kselftest, linux-kernel

On Sun, Oct 11, 2026 at 3:34 PM Sasha Levin <sashal@kernel.org> 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@kernel.org>

Reviewed-by: T.J. Mercier <tjmercier@google.com>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] selftests: memcg: don't close an uninitialized fd
  2026-10-11 22:33 [PATCH] selftests: memcg: don't close an uninitialized fd Sasha Levin
  2026-10-12 12:45 ` Michal Koutný
  2026-10-12 14:09 ` T.J. Mercier
@ 2026-10-12 17:08 ` Shakeel Butt
  2026-10-12 17:54 ` Tejun Heo
  3 siblings, 0 replies; 5+ messages in thread
From: Shakeel Butt @ 2026-10-12 17:08 UTC (permalink / raw)
  To: Sasha Levin
  Cc: Johannes Weiner, Michal Hocko, Roman Gushchin, Muchun Song,
	Tejun Heo, Michal Koutný, Shuah Khan, Greg Kroah-Hartman,
	T.J. Mercier, Amir Goldstein, cgroups, linux-mm, linux-kselftest,
	linux-kernel

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@kernel.org>

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


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] selftests: memcg: don't close an uninitialized fd
  2026-10-11 22:33 [PATCH] selftests: memcg: don't close an uninitialized fd Sasha Levin
                   ` (2 preceding siblings ...)
  2026-10-12 17:08 ` Shakeel Butt
@ 2026-10-12 17:54 ` Tejun Heo
  3 siblings, 0 replies; 5+ messages in thread
From: Tejun Heo @ 2026-10-12 17:54 UTC (permalink / raw)
  To: Sasha Levin
  Cc: Johannes Weiner, Michal Hocko, Roman Gushchin, Shakeel Butt,
	Muchun Song, Michal Koutný, Shuah Khan, Greg Kroah-Hartman,
	T.J. Mercier, Amir Goldstein, cgroups, linux-mm, linux-kselftest,
	linux-kernel

Applied to cgroup/for-7.4 with the subject capitalized and the Fixes tag
dropped.

Thanks.

-- 
tejun

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-10-12 17:54 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-11 22:33 [PATCH] selftests: memcg: don't close an uninitialized fd Sasha Levin
2026-10-12 12:45 ` Michal Koutný
2026-10-12 14:09 ` T.J. Mercier
2026-10-12 17:08 ` Shakeel Butt
2026-10-12 17:54 ` Tejun Heo

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.