drm/i915: release struct_mutex on the i915_gem_init_hw fail path
authorJani Nikula <jani.nikula@intel.com>
Fri, 5 Dec 2014 12:17:42 +0000 (14:17 +0200)
committerDaniel Vetter <daniel.vetter@ffwll.ch>
Fri, 5 Dec 2014 14:03:44 +0000 (15:03 +0100)
Release struct_mutex if init_rings() fails.

This is a regression introduced in
commit 35a57ffbb10840af219eeaf64718434242bb7c76
Author: Daniel Vetter <daniel.vetter@ffwll.ch>
Date:   Thu Nov 20 00:33:07 2014 +0100

    drm/i915: Only init engines once

Reported-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
drivers/gpu/drm/i915/i915_gem.c

index c1c11418231bd0a80722dac8d8cf36c6f2c6f477..e3ce4bef22a3665d77bd1c5888a5e4bb442f07a2 100644 (file)
@@ -4860,22 +4860,18 @@ int i915_gem_init(struct drm_device *dev)
        }
 
        ret = i915_gem_init_userptr(dev);
-       if (ret) {
-               mutex_unlock(&dev->struct_mutex);
-               return ret;
-       }
+       if (ret)
+               goto out_unlock;
 
        i915_gem_init_global_gtt(dev);
 
        ret = i915_gem_context_init(dev);
-       if (ret) {
-               mutex_unlock(&dev->struct_mutex);
-               return ret;
-       }
+       if (ret)
+               goto out_unlock;
 
        ret = dev_priv->gt.init_rings(dev);
        if (ret)
-               return ret;
+               goto out_unlock;
 
        ret = i915_gem_init_hw(dev);
        if (ret == -EIO) {
@@ -4887,6 +4883,8 @@ int i915_gem_init(struct drm_device *dev)
                atomic_set_mask(I915_WEDGED, &dev_priv->gpu_error.reset_counter);
                ret = 0;
        }
+
+out_unlock:
        mutex_unlock(&dev->struct_mutex);
 
        return ret;