Skip to content

Commit

Permalink
cgroup: fix an error handling path in alloc_pagecache_max_30M()
Browse files Browse the repository at this point in the history
If the first goto is taken, 'fd' is not opened yet (and is un-initialized).
So a direct return is safer.

Link: https://lkml.kernel.org/r/628312312eb40e0e39463a2c06415fde5295c716.1653229120.git.christophe.jaillet@wanadoo.fr
Fixes: c1a31a2 ("cgroup: fix racy check in alloc_pagecache_max_30M() helper function")
Signed-off-by: Christophe JAILLET <[email protected]>
Reviewed-by: Andrew Morton <[email protected]>
Cc: Dan Carpenter <[email protected]>
Cc: Johannes Weiner <[email protected]>
Cc: Michal Hocko <[email protected]>
Cc: Roman Gushchin <[email protected]>
Cc: Shakeel Butt <[email protected]>
Cc: Muchun Song <[email protected]>
Cc: Tejun Heo <[email protected]>
Cc: Zefan Li <[email protected]>
Cc: Shuah Khan <[email protected]>
Cc: David Vernet <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
  • Loading branch information
tititiou36 authored and akpm00 committed May 25, 2022
1 parent 02e34ff commit 7fb6378
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion tools/testing/selftests/cgroup/test_memcontrol.c
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,7 @@ static int alloc_pagecache_max_30M(const char *cgroup, void *arg)
high = cg_read_long(cgroup, "memory.high");
max = cg_read_long(cgroup, "memory.max");
if (high != MB(30) && max != MB(30))
goto cleanup;
return -1;

fd = get_temp_fd();
if (fd < 0)
Expand Down

0 comments on commit 7fb6378

Please sign in to comment.