summaryrefslogtreecommitdiff
path: root/tests/kms_universal_plane.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 /tests/kms_universal_plane.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 'tests/kms_universal_plane.c')
-rw-r--r--tests/kms_universal_plane.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/tests/kms_universal_plane.c b/tests/kms_universal_plane.c
index 991204ce..39fa1f1d 100644
--- a/tests/kms_universal_plane.c
+++ b/tests/kms_universal_plane.c
@@ -26,6 +26,7 @@
#include <stdbool.h>
#include <stdio.h>
#include <string.h>
+#include <fcntl.h>
typedef struct {
@@ -549,13 +550,16 @@ i915_gem_fb_count(data_t *data)
{
char buf[1024];
FILE *fp;
+ int fd;
int count = 0;
- fp = igt_debugfs_fopen(data->drm_fd, "i915_gem_framebuffer", "r");
+ fd = igt_debugfs_open(data->drm_fd, "i915_gem_framebuffer", O_RDONLY);
+ fp = fdopen(fd, "r");
igt_require(fp);
while (fgets(buf, sizeof(buf), fp) != NULL)
count++;
fclose(fp);
+ close(fd);
return count;
}