Skip to contentSkip to conversation

lib/debugfs: Close dir before returning open debugs file

PATCH In review Ander Conselvan de Oliveira 2 participants 2 messages Apr 7, 2017 Library code

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 lib/debugfs: Close dir before returning open debugs file

The function igt_debugfs_open() would not close the debugfs dir before returning. Tests that do a lot of pipe CRC comparaions, such as kms_cursor_crc, would eventually fail.

(kms_cursor_crc:3853) igt-debugfs-CRITICAL: Test assertion failure function igt_pipe_crc_do_start, file igt_debugfs.c:387:
(kms_cursor_crc:3853) igt-debugfs-CRITICAL: Failed assertion: err == 0
(kms_cursor_crc:3853) igt-debugfs-CRITICAL: Last errno: 24, Too many open files
(kms_cursor_crc:3853) igt-debugfs-CRITICAL: error: -24 != 0

83884e97e187 ("Restore "lib: Open debugfs files for the given DRM device"")

---
 lib/igt_debugfs.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
lib/igt_debugfs.c +6 -2
index d64694c..fb6d521 100644
@@ -212,13 +212,17 @@ int igt_debugfs_dir(int device)
  */
 int igt_debugfs_open(int device, const char *filename, int mode)
 {
-	int dir;
+	int dir, ret;
 
 	dir = igt_debugfs_dir(device);
 	if (dir < 0)
 		return dir;
 
-	return openat(dir, filename, mode);
+	ret = openat(dir, filename, mode);
+
+	close(dir);
+
+	return ret;
 }
 
 /**
Signature · 6 lines
2.9.3

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Reviewed-by on v1 1/1
#1 lore raw
Quoted 8 lines · Ander Conselvan de Oliveira

The function igt_debugfs_open() would not close the debugfs dir before returning. Tests that do a lot of pipe CRC comparaions, such as kms_cursor_crc, would eventually fail.

(kms_cursor_crc:3853) igt-debugfs-CRITICAL: Test assertion failure function igt_pipe_crc_do_start, file igt_debugfs.c:387:
(kms_cursor_crc:3853) igt-debugfs-CRITICAL: Failed assertion: err == 0
(kms_cursor_crc:3853) igt-debugfs-CRITICAL: Last errno: 24, Too many open files
(kms_cursor_crc:3853) igt-debugfs-CRITICAL: error: -24 != 0

Whoops. Also for any test that repeatedly opens a debugfs, please do move the igt_debugfs_dir() into the caller so we can cache the lookup inside the fd.

Quoted 3 lines

83884e97e187 ("Restore "lib: Open debugfs files for the given DRM device"")

-Chris

Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx