1
0
Fork 0

kselftests: cgroup: Avoid the reuse of fd after it is deallocated

[ Upstream commit d671fa6393 ]

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: 5313bfe425 ("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>
5.4-rM2-2.2.x-imx-squashed
Hewenliang 2019-11-11 21:16:55 -05:00 committed by Greg Kroah-Hartman
parent c570172d62
commit 83ff921a5e
1 changed files with 1 additions and 0 deletions

View File

@ -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;