xf86drm: drmGetDevice2: error out if the fd has unknown subsys
authorEmil Velikov <emil.velikov@collabora.com>
Tue, 15 May 2018 15:43:58 +0000 (16:43 +0100)
committerEmil Velikov <emil.l.velikov@gmail.com>
Tue, 24 Jul 2018 15:24:04 +0000 (16:24 +0100)
Currently one can open() any /dev node. If it's unknown
drmParseSubsystemType() will return an error.

Track that and bail as needed.

Signed-off-by: Emil Velikov <emil.velikov@collabora.com>
Tested-by: Robert Foss <robert.foss@collabora.com>
Reviewed-by: Robert Foss <robert.foss@collabora.com>
Reviewed-by: Eric Engestrom <eric@engestrom.ch>
xf86drm.c

index 87c216c..e1bbbe9 100644 (file)
--- a/xf86drm.c
+++ b/xf86drm.c
@@ -3814,6 +3814,8 @@ int drmGetDevice2(int fd, uint32_t flags, drmDevicePtr *device)
         return -EINVAL;
 
     subsystem_type = drmParseSubsystemType(maj, min);
+    if (subsystem_type < 0)
+        return subsystem_type;
 
     local_devices = calloc(max_count, sizeof(drmDevicePtr));
     if (local_devices == NULL)