xf86-video-intel: src/intel_device.c

Chris Wilson ickle at kemper.freedesktop.org
Thu Feb 8 17:22:39 UTC 2018


 src/intel_device.c |   10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

New commits:
commit 5c7e4e0e05b37e038c9047e9d6cae118799f6ad2
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Thu Feb 8 17:20:55 2018 +0000

    intel: Only check file type bits not mode when searching for rendernodes
    
    Before checking st_rdev, we first need to validate that the file is a
    device node, but we only want to check the file type bits and not
    compare the permissions.
    
    Reported-by: Ilia Mirkin <imirkin at alum.mit.edu>
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/intel_device.c b/src/intel_device.c
index c4910cd8..21955073 100644
--- a/src/intel_device.c
+++ b/src/intel_device.c
@@ -467,7 +467,7 @@ static char *find_master_node(int fd)
 
 	sprintf(buf, "/dev/dri/card%d", (int)(st.st_rdev & 0x7f));
 	if (stat(buf, &master) == 0 &&
-	    st.st_mode == master.st_mode &&
+	    S_ISCHR(master.st_mode) &&
 	    (st.st_rdev & 0x7f) == master.st_rdev)
 		return strdup(buf);
 
@@ -478,10 +478,10 @@ static char *find_master_node(int fd)
 static int is_render_node(int fd, struct stat *st)
 {
 	if (fstat(fd, st))
-		return 0;
+		return -1;
 
 	if (!S_ISCHR(st->st_mode))
-		return 0;
+		return -1;
 
 	return st->st_rdev & 0x80;
 }
@@ -498,7 +498,7 @@ static char *find_render_node(int fd)
 
 	sprintf(buf, "/dev/dri/renderD%d", (int)((master.st_rdev | 0x80) & 0xbf));
 	if (stat(buf, &render) == 0 &&
-	    master.st_mode == render.st_mode &&
+	    S_ISCHR(render.st_mode) &&
 	    render.st_rdev == (master.st_rdev | 0x80))
 		return strdup(buf);
 
@@ -506,7 +506,7 @@ static char *find_render_node(int fd)
 	for (i = 0; i < 16; i++) {
 		sprintf(buf, "/dev/dri/renderD%d", i + 128);
 		if (stat(buf, &render) == 0 &&
-		    master.st_mode == render.st_mode &&
+		    S_ISCHR(render.st_mode) &&
 		    render.st_rdev == (master.st_rdev | 0x80))
 			return strdup(buf);
 	}


More information about the xorg-commit mailing list