| From f467781781875a277b9a0b8f25eb145a4bc50e12 Mon Sep 17 00:00:00 2001 |
| From: Hewenliang <hewenliang4@huawei.com> |
| Date: Mon, 11 Nov 2019 21:16:55 -0500 |
| Subject: [PATCH] kselftests: cgroup: Avoid the reuse of fd after it is |
| deallocated |
| |
| commit d671fa6393d6788fc65555d4643b71cb3a361f36 upstream. |
| |
| 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> |
| Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com> |
| |
| diff --git a/tools/testing/selftests/cgroup/test_freezer.c b/tools/testing/selftests/cgroup/test_freezer.c |
| index 2bfddb6d6d3b..ed7057733e05 100644 |
| --- a/tools/testing/selftests/cgroup/test_freezer.c |
| +++ b/tools/testing/selftests/cgroup/test_freezer.c |
| @@ -73,6 +73,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; |
| -- |
| 2.7.4 |
| |