]> git.baikalelectronics.ru Git - kernel.git/commitdiff
drm/i915: Use the correct destructor for freeing requests on error
authorChris Wilson <chris@chris-wilson.co.uk>
Thu, 21 May 2015 20:01:45 +0000 (21:01 +0100)
committerDaniel Vetter <daniel.vetter@ffwll.ch>
Fri, 22 May 2015 06:53:48 +0000 (08:53 +0200)
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 cc2b10c66ee2a05b50fe980695a1f0759fee23c5
Author: Chris Wilson <chris@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@chris-wilson.co.uk>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
drivers/gpu/drm/i915/i915_gem.c

index 50e49a3d7e51c218afb7582ab62cb247f3d52695..0ce3e4b3059eda516f1c15541a2da6a8aba7da80 100644 (file)
@@ -2653,10 +2653,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;
 
@@ -2664,13 +2662,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 *