summaryrefslogtreecommitdiff
path: root/tools/intel_dp_compliance.c
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2017-03-24 20:52:44 +0000
committerChris Wilson <chris@chris-wilson.co.uk>2017-03-24 21:35:25 +0000
commite08ed8a272fda96b8f7224985177f313c3b2ddf6 (patch)
tree5fdba2e2cade4db9f64582e6414c3372a5681180 /tools/intel_dp_compliance.c
parent58de785468782f29e6eb1d32d47b55b3d234dfcf (diff)
lib/debugfs: Phase out igt_debugfs_fopen()
Wrapping fdopen() proved dangerous, the underlying fd is not refcounted, and we must close it in the library or else we easily leak and exhaust all fd. Since we can't provide igt_debugfs_fopen(), move the burden onto the caller for those that require a stream FILE*. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'tools/intel_dp_compliance.c')
-rw-r--r--tools/intel_dp_compliance.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/tools/intel_dp_compliance.c b/tools/intel_dp_compliance.c
index 4b4d255d..c40548e7 100644
--- a/tools/intel_dp_compliance.c
+++ b/tools/intel_dp_compliance.c
@@ -227,17 +227,27 @@ static void clear_test_active(void)
fflush(test_active_fp);
}
+static FILE *fopenat(int dir, const char *name, const char *mode)
+{
+ int fd = openat(dir, name, O_RDWR);
+ return fdopen(fd, mode);
+}
+
static void setup_debugfs_files(void)
{
- test_type_fp = igt_debugfs_fopen(drm_fd, INTEL_DP_TEST_TYPE_FILE, "r");
+ int dir = igt_debugfs_dir(drm_fd);
+
+ test_type_fp = fopenat(dir, INTEL_DP_TEST_TYPE_FILE, "r");
igt_require(test_type_fp);
- test_data_fp = igt_debugfs_fopen(drm_fd, INTEL_DP_TEST_DATA_FILE, "r");
+ test_data_fp = fopenat(dir, INTEL_DP_TEST_DATA_FILE, "r");
igt_require(test_data_fp);
- test_active_fp = igt_debugfs_fopen(drm_fd, INTEL_DP_TEST_ACTIVE_FILE, "w+");
+ test_active_fp = fopenat(dir, INTEL_DP_TEST_ACTIVE_FILE, "w+");
igt_require(test_active_fp);
+ close(dir);
+
/* Reset the active flag for safety */
clear_test_active();
}