Commit d671fa63 authored by Hewenliang's avatar Hewenliang Committed by Tejun Heo

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: 5313bfe4 ("selftests: cgroup: add freezer controller self-tests")
Signed-off-by: default avatarHewenliang <hewenliang4@huawei.com>
Signed-off-by: default avatarTejun Heo <tj@kernel.org>
parent 742e8cd3
......@@ -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;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment