drm/msm: grab struct_mutex after allocating submit
authorRob Clark <robdclark@gmail.com>
Wed, 3 Feb 2016 18:24:35 +0000 (13:24 -0500)
committerRob Clark <robdclark@gmail.com>
Thu, 3 Mar 2016 16:55:30 +0000 (11:55 -0500)
No real need to hold the lock over allocation, and simplifies things
slightly if we change the order.

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

index 06f6ea9..43d2181 100644 (file)
@@ -339,13 +339,11 @@ int msm_ioctl_gem_submit(struct drm_device *dev, void *data,
        if (args->nr_cmds > MAX_CMDS)
                return -EINVAL;
 
-       mutex_lock(&dev->struct_mutex);
-
        submit = submit_create(dev, gpu, args->nr_bos);
-       if (!submit) {
-               ret = -ENOMEM;
-               goto out;
-       }
+       if (!submit)
+               return -ENOMEM;
+
+       mutex_lock(&dev->struct_mutex);
 
        ret = submit_lookup_objects(submit, args, file);
        if (ret)
@@ -420,8 +418,7 @@ int msm_ioctl_gem_submit(struct drm_device *dev, void *data,
        args->fence = submit->fence;
 
 out:
-       if (submit)
-               submit_cleanup(submit, !!ret);
+       submit_cleanup(submit, !!ret);
        mutex_unlock(&dev->struct_mutex);
        return ret;
 }