diff mbox

[i-g-t] lib/igt_kms: Fix passing invalid fd to openat(2).

Message ID 1464966379-20382-1-git-send-email-marius.c.vlad@intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Marius Vlad June 3, 2016, 3:06 p.m. UTC
Introduced by 0e11befe442. openat(2) uses a relative path. Fix by
passing the correct fd.

Signed-off-by: Marius Vlad <marius.c.vlad@intel.com>
CC: Chris Wilson <chris@chris-wilson.co.uk>
---
 lib/igt_kms.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Chris Wilson June 3, 2016, 5:09 p.m. UTC | #1
On Fri, Jun 03, 2016 at 06:06:19PM +0300, Marius Vlad wrote:
> Introduced by 0e11befe442. openat(2) uses a relative path. Fix by
> passing the correct fd.
> 
> Signed-off-by: Marius Vlad <marius.c.vlad@intel.com>
> CC: Chris Wilson <chris@chris-wilson.co.uk>

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

> ---
>  lib/igt_kms.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/lib/igt_kms.c b/lib/igt_kms.c
> index b12a5b3..135c7b8 100644
> --- a/lib/igt_kms.c
> +++ b/lib/igt_kms.c
> @@ -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.

> +	if (!igt_sysfs_set(dir, path, value)) {
>  		close(dir);
>  		return false;
>  	}

Preferrably without the comment,
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
-Chris
diff mbox

Patch

diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index b12a5b3..135c7b8 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -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;
 	}