Skip to contentSkip to conversation

lib/igt_kms: Fix passing invalid fd to openat(2).

PATCH In review Marius Vlad 2 participants 2 messages Jun 3, 2016 Library code

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 lib/igt_kms: Fix passing invalid fd to openat(2).

Introduced by 0e11befe442. openat(2) uses a relative path. Fix by passing the correct fd.

---
 lib/igt_kms.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
lib/igt_kms.c +2 -1
index b12a5b3..135c7b8 100644
@@ -641,7 +641,8 @@ bool kmstest_force_connector(int drm_fd, drmModeConnector *connector,
 		return false;
 	}
 
-	if (!igt_sysfs_set(drm_fd, path, value)) {
+	/* use the fd returned by igt_sysfs_open() */
+	if (!igt_sysfs_set(dir, path, value)) {
 		close(dir);
 		return false;
 	}
Signature · 6 lines
2.5.0

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Reviewed-by on v1 1/1
#1 lore raw
Quoted 5 lines · Marius Vlad

Introduced by 0e11befe442. openat(2) uses a relative path. Fix by passing the correct fd.

Yup, At one point it was using the drm_fd to search for the right sysfs every time,

Quoted 9 lines
---
 lib/igt_kms.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
lib/igt_kms.c +0 -0
index b12a5b3..135c7b8 100644

lib/igt_kms.c bool kmstest_force_connector(int drm_fd, drmModeConnector *connector, · line 644

Quoted 5 lines
lib/igt_kms.c +1 -1
@@ -641,7 +641,8 @@ bool kmstest_force_connector(int drm_fd, drmModeConnector *connector,
 		return false;
 	}
 
-	if (!igt_sysfs_set(drm_fd, path, value)) {
+	/* use the fd returned by igt_sysfs_open() */

Just call it dir, don't tell people they can treat it as an fd.

lib/igt_kms.c bool kmstest_force_connector(int drm_fd, drmModeConnector *connector, · line 648

Quoted 4 lines
lib/igt_kms.c +1 -0
+	if (!igt_sysfs_set(dir, path, value)) {
 		close(dir);
 		return false;
 	}

Preferrably without the comment,

-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