diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2021-01-28 22:59:43 +0000 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2021-01-28 23:11:30 +0000 |
commit | e1e5b3fea2baafdae0160940ecb8bf0242703840 (patch) | |
tree | 37217eb38b3f223c7a4965141cef0bb777f2899a /tests/debugfs_test.c | |
parent | 0b6967520b15e73773eace7937ed8c17ba411bc0 (diff) |
debugfs_test: Protect against disappearing directories
With the introduction of sysfs/clients, we have dynamic directories that
may disappear underneath the fswalker.
Closes: https://gitlab.freedesktop.org/drm/intel/-/issues/3017
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Acked-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Diffstat (limited to 'tests/debugfs_test.c')
-rw-r--r-- | tests/debugfs_test.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/tests/debugfs_test.c b/tests/debugfs_test.c index f6cf1fa0..46ba0a8b 100644 --- a/tests/debugfs_test.c +++ b/tests/debugfs_test.c @@ -50,11 +50,15 @@ static void read_and_discard_sysfs_entries(int path_fd, int indent) if (!strcmp(dirent->d_name, ".") || !strcmp(dirent->d_name, "..")) continue; + if (dirent->d_type == DT_DIR) { - int sub_fd = -1; - igt_assert((sub_fd = - openat(path_fd, dirent->d_name, O_RDONLY | - O_DIRECTORY)) > 0); + int sub_fd; + + sub_fd = openat(path_fd, dirent->d_name, + O_RDONLY | O_DIRECTORY); + if (sub_fd < 0) + continue; + igt_debug("%sEntering subdir %s\n", tabs, dirent->d_name); read_and_discard_sysfs_entries(sub_fd, indent + 1); close(sub_fd); |