2018-04-04 07:41:56

by Xidong Wang

[permalink] [raw]
Subject: [PATCH 1/1] drm/i915: Do not use kfree() to free kmem_cache_alloc() return value

In eb_lookup_vmas(), the return value of kmem_cache_alloc() is freed
with kfree(). I think the expected paired function is kmem_cahce_free().

Signed-off-by: Xidong Wang <[email protected]>
---
drivers/gpu/drm/i915/i915_gem_execbuffer.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/i915/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
index 8c170db..0414228 100644
--- a/drivers/gpu/drm/i915/i915_gem_execbuffer.c
+++ b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
@@ -728,7 +728,7 @@ static int eb_lookup_vmas(struct i915_execbuffer *eb)

err = radix_tree_insert(handles_vma, handle, vma);
if (unlikely(err)) {
- kfree(lut);
+ kmem_cache_free(eb->i915->luts, lut);
goto err_obj;
}

--
2.7.4




2018-04-04 07:59:00

by Chris Wilson

[permalink] [raw]
Subject: Re: [PATCH 1/1] drm/i915: Do not use kfree() to free kmem_cache_alloc() return value

Quoting Xidong Wang (2018-04-04 08:37:54)
> In eb_lookup_vmas(), the return value of kmem_cache_alloc() is freed
> with kfree(). I think the expected paired function is kmem_cahce_free().
>
> Signed-off-by: Xidong Wang <[email protected]>

That is indeed what it should be doing,

Fixes: d1b48c1e7184 ("drm/i915: Replace execbuf vma ht with an idr")
Cc: Chris Wilson <[email protected]>
Cc: Tvrtko Ursulin <[email protected]>
Cc: <[email protected]> # v4.14+
Reviewed-by: Chris Wilson <[email protected]>
-Chris

2018-04-04 20:56:15

by Chris Wilson

[permalink] [raw]
Subject: Re: [PATCH 1/1] drm/i915: Do not use kfree() to free kmem_cache_alloc() return value

Quoting Xidong Wang (2018-04-04 08:37:54)
> In eb_lookup_vmas(), the return value of kmem_cache_alloc() is freed
> with kfree(). I think the expected paired function is kmem_cahce_free().
>
> Signed-off-by: Xidong Wang <[email protected]>

Thank you for the fix; applied.
-Chris