Commit dd785e35 authored by Chris Wilson's avatar Chris Wilson Committed by Eric Anholt

drm/i915/ringbuffer: Set ring->gem_buffer = NULL on init unwind

The cleanup path for early abort failed to nullify the gem_buffer. The
likely consequence of this is zero, since a failure here should mean
aborting the module load.
Signed-off-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: default avatarEric Anholt <eric@anholt.net>
parent debcaddc
...@@ -608,9 +608,10 @@ static int init_status_page(struct drm_device *dev, ...@@ -608,9 +608,10 @@ static int init_status_page(struct drm_device *dev,
int intel_init_ring_buffer(struct drm_device *dev, int intel_init_ring_buffer(struct drm_device *dev,
struct intel_ring_buffer *ring) struct intel_ring_buffer *ring)
{ {
int ret;
struct drm_i915_gem_object *obj_priv; struct drm_i915_gem_object *obj_priv;
struct drm_gem_object *obj; struct drm_gem_object *obj;
int ret;
ring->dev = dev; ring->dev = dev;
if (I915_NEED_GFX_HWS(dev)) { if (I915_NEED_GFX_HWS(dev)) {
...@@ -623,16 +624,14 @@ int intel_init_ring_buffer(struct drm_device *dev, ...@@ -623,16 +624,14 @@ int intel_init_ring_buffer(struct drm_device *dev,
if (obj == NULL) { if (obj == NULL) {
DRM_ERROR("Failed to allocate ringbuffer\n"); DRM_ERROR("Failed to allocate ringbuffer\n");
ret = -ENOMEM; ret = -ENOMEM;
goto cleanup; goto err_hws;
} }
ring->gem_object = obj; ring->gem_object = obj;
ret = i915_gem_object_pin(obj, ring->alignment); ret = i915_gem_object_pin(obj, ring->alignment);
if (ret != 0) { if (ret)
drm_gem_object_unreference(obj); goto err_unref;
goto cleanup;
}
obj_priv = to_intel_bo(obj); obj_priv = to_intel_bo(obj);
ring->map.size = ring->size; ring->map.size = ring->size;
...@@ -644,18 +643,14 @@ int intel_init_ring_buffer(struct drm_device *dev, ...@@ -644,18 +643,14 @@ int intel_init_ring_buffer(struct drm_device *dev,
drm_core_ioremap_wc(&ring->map, dev); drm_core_ioremap_wc(&ring->map, dev);
if (ring->map.handle == NULL) { if (ring->map.handle == NULL) {
DRM_ERROR("Failed to map ringbuffer.\n"); DRM_ERROR("Failed to map ringbuffer.\n");
i915_gem_object_unpin(obj);
drm_gem_object_unreference(obj);
ret = -EINVAL; ret = -EINVAL;
goto cleanup; goto err_unpin;
} }
ring->virtual_start = ring->map.handle; ring->virtual_start = ring->map.handle;
ret = ring->init(dev, ring); ret = ring->init(dev, ring);
if (ret != 0) { if (ret)
intel_cleanup_ring_buffer(dev, ring); goto err_unmap;
return ret;
}
if (!drm_core_check_feature(dev, DRIVER_MODESET)) if (!drm_core_check_feature(dev, DRIVER_MODESET))
i915_kernel_lost_context(dev); i915_kernel_lost_context(dev);
...@@ -669,7 +664,15 @@ int intel_init_ring_buffer(struct drm_device *dev, ...@@ -669,7 +664,15 @@ int intel_init_ring_buffer(struct drm_device *dev,
INIT_LIST_HEAD(&ring->active_list); INIT_LIST_HEAD(&ring->active_list);
INIT_LIST_HEAD(&ring->request_list); INIT_LIST_HEAD(&ring->request_list);
return ret; return ret;
cleanup:
err_unmap:
drm_core_ioremapfree(&ring->map, dev);
err_unpin:
i915_gem_object_unpin(obj);
err_unref:
drm_gem_object_unreference(obj);
ring->gem_object = NULL;
err_hws:
cleanup_status_page(dev, ring); cleanup_status_page(dev, ring);
return ret; return ret;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment