drm/i915: Fix set_caching locking
authorBen Widawsky <ben@bwidawsk.net>
Wed, 26 Sep 2012 23:15:20 +0000 (16:15 -0700)
committerDaniel Vetter <daniel.vetter@ffwll.ch>
Thu, 27 Sep 2012 06:45:11 +0000 (08:45 +0200)
On the EINVAL case we don't release struct_mutex. It should be safe to
grab the lock after checking the parameters, which also resolves the
issues.

Signed-off-by: Ben Widawsky <ben@bwidawsk.net>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
drivers/gpu/drm/i915/i915_gem.c

index 365a7dc8a4a896bb3321715f32f203e51f90aa96..76bbb379d389b93c78353425ec095d633b8a8663 100644 (file)
@@ -3218,10 +3218,6 @@ int i915_gem_set_caching_ioctl(struct drm_device *dev, void *data,
        enum i915_cache_level level;
        int ret;
 
-       ret = i915_mutex_lock_interruptible(dev);
-       if (ret)
-               return ret;
-
        switch (args->caching) {
        case I915_CACHING_NONE:
                level = I915_CACHE_NONE;
@@ -3233,6 +3229,10 @@ int i915_gem_set_caching_ioctl(struct drm_device *dev, void *data,
                return -EINVAL;
        }
 
+       ret = i915_mutex_lock_interruptible(dev);
+       if (ret)
+               return ret;
+
        obj = to_intel_bo(drm_gem_object_lookup(dev, file, args->handle));
        if (&obj->base == NULL) {
                ret = -ENOENT;