diff mbox

[libdrm,01/10] xf86drm: drmGetDevice2: error out if the fd has unknown subsys

Message ID 20180625173626.8046-1-emil.l.velikov@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Emil Velikov June 25, 2018, 5:36 p.m. UTC
From: Emil Velikov <emil.velikov@collabora.com>

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>
---
 xf86drm.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Robert Foss June 28, 2018, 10:11 a.m. UTC | #1
This series has been:
Tested-by: Robert Foss <robert.foss@collabora.com>

On 2018-06-25 19:36, Emil Velikov wrote:
> From: Emil Velikov <emil.velikov@collabora.com>
> 
> 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>
> ---
>   xf86drm.c | 2 ++
>   1 file changed, 2 insertions(+)
> 
> diff --git a/xf86drm.c b/xf86drm.c
> index 87c216cf..e1bbbe99 100644
> --- 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)
>
Robert Foss June 28, 2018, 10:11 a.m. UTC | #2
Feel free to add my r-b to this patch.

On 2018-06-25 19:36, Emil Velikov wrote:
> From: Emil Velikov <emil.velikov@collabora.com>
> 
> 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>
> ---
>   xf86drm.c | 2 ++
>   1 file changed, 2 insertions(+)
> 
> diff --git a/xf86drm.c b/xf86drm.c
> index 87c216cf..e1bbbe99 100644
> --- 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)
>
diff mbox

Patch

diff --git a/xf86drm.c b/xf86drm.c
index 87c216cf..e1bbbe99 100644
--- 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)