Skip to content

Commit 83ff921

Browse files
hewenliang4gregkh
authored andcommitted
kselftests: cgroup: Avoid the reuse of fd after it is deallocated
[ Upstream commit d671fa6 ] It is necessary to set fd to -1 when inotify_add_watch() fails in cg_prepare_for_wait. Otherwise the fd which has been closed in cg_prepare_for_wait may be misused in other functions such as cg_enter_and_wait_for_frozen and cg_freeze_wait. Fixes: 5313bfe ("selftests: cgroup: add freezer controller self-tests") Signed-off-by: Hewenliang <hewenliang4@huawei.com> Signed-off-by: Tejun Heo <tj@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent c570172 commit 83ff921

1 file changed

Lines changed: 1 addition & 0 deletions

File tree

tools/testing/selftests/cgroup/test_freezer.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ static int cg_prepare_for_wait(const char *cgroup)
7272
if (ret == -1) {
7373
debug("Error: inotify_add_watch() failed\n");
7474
close(fd);
75+
fd = -1;
7576
}
7677

7778
return fd;

0 commit comments

Comments
 (0)