drm/msm: reject submit ioctl if no gpu
authorRob Clark <robdclark@gmail.com>
Wed, 3 Feb 2016 18:12:31 +0000 (13:12 -0500)
committerRob Clark <robdclark@gmail.com>
Thu, 3 Mar 2016 16:55:30 +0000 (11:55 -0500)
Existing userspace wouldn't get this far, since getparam ioctl would
have failed and it would have bailed out creating a screen/context.

But all the same, we shouldn't let evil or confused userspace cause a
null ptr deref.

Signed-off-by: Rob Clark <robdclark@gmail.com>
drivers/gpu/drm/msm/msm_gem_submit.c

index 6d7cd3fe21e70b665aebf4eb76ffa28b8e1e266f..06f6ea9ccba0b56377f5d42ae5471604d8645bb3 100644 (file)
@@ -323,18 +323,19 @@ int msm_ioctl_gem_submit(struct drm_device *dev, void *data,
        struct drm_msm_gem_submit *args = data;
        struct msm_file_private *ctx = file->driver_priv;
        struct msm_gem_submit *submit;
-       struct msm_gpu *gpu;
+       struct msm_gpu *gpu = priv->gpu;
        unsigned i;
        int ret;
 
+       if (!gpu)
+               return -ENXIO;
+
        /* for now, we just have 3d pipe.. eventually this would need to
         * be more clever to dispatch to appropriate gpu module:
         */
        if (args->pipe != MSM_PIPE_3D0)
                return -EINVAL;
 
-       gpu = priv->gpu;
-
        if (args->nr_cmds > MAX_CMDS)
                return -EINVAL;