[Intel-gfx] [PATCH 1/4] drm/i915: Use the correct destructor for freeing requests on error

Chris Wilson chris at chris-wilson.co.uk
Thu May 21 13:01:45 PDT 2015


After allocating from the slab cache, we then need to free the request
back into the slab cache upon error (and not call kfree as that leads
to eventual memory corruption).

Fixes regression from
commit efab6d8dd158fdccbe6a030f89fbf9ca0a9564e4
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Tue Apr 7 16:20:57 2015 +0100

    drm/i915: Use a separate slab for requests

Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
Cc: Daniel Vetter <daniel.vetter at ffwll.ch>
---
 drivers/gpu/drm/i915/i915_gem.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index bd43dd1e9666..870ba67a595f 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -2627,10 +2627,8 @@ int i915_gem_request_alloc(struct intel_engine_cs *ring,
 	req->i915 = dev_priv;
 
 	ret = i915_gem_get_seqno(ring->dev, &req->seqno);
-	if (ret) {
-		kfree(req);
-		return ret;
-	}
+	if (ret)
+		goto err;
 
 	req->ring = ring;
 
@@ -2638,13 +2636,15 @@ int i915_gem_request_alloc(struct intel_engine_cs *ring,
 		ret = intel_logical_ring_alloc_request_extras(req, ctx);
 	else
 		ret = intel_ring_alloc_request_extras(req);
-	if (ret) {
-		kfree(req);
-		return ret;
-	}
+	if (ret)
+		goto err;
 
 	ring->outstanding_lazy_request = req;
 	return 0;
+
+err:
+	kmem_cache_free(dev_priv->requests, req);
+	return ret;
 }
 
 struct drm_i915_gem_request *
-- 
2.1.4



More information about the Intel-gfx mailing list