summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHewenliang <hewenliang4@huawei.com>2019-11-11 21:16:55 -0500
committerTejun Heo <tj@kernel.org>2019-11-12 07:33:59 -0800
commitd671fa6393d6788fc65555d4643b71cb3a361f36 (patch)
treec43826119de8184262cca1c55d08a4b6cc4fdee7
parent742e8cd3e1ba6f19cad6d912f8d469df5557d0fd (diff)
downloadlinux-d671fa6393d6788fc65555d4643b71cb3a361f36.tar.bz2
kselftests: cgroup: Avoid the reuse of fd after it is deallocated
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: 5313bfe425c8 ("selftests: cgroup: add freezer controller self-tests") Signed-off-by: Hewenliang <hewenliang4@huawei.com> Signed-off-by: Tejun Heo <tj@kernel.org>
-rw-r--r--tools/testing/selftests/cgroup/test_freezer.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/tools/testing/selftests/cgroup/test_freezer.c b/tools/testing/selftests/cgroup/test_freezer.c
index aadc52a1a1b1..23d8fa4a3e4e 100644
--- a/tools/testing/selftests/cgroup/test_freezer.c
+++ b/tools/testing/selftests/cgroup/test_freezer.c
@@ -72,6 +72,7 @@ static int cg_prepare_for_wait(const char *cgroup)
if (ret == -1) {
debug("Error: inotify_add_watch() failed\n");
close(fd);
+ fd = -1;
}
return fd;