drm/i915: Fix vma resource freeing
authorThomas Hellström <thomas.hellstrom@linux.intel.com>
Wed, 19 Jan 2022 17:47:34 +0000 (18:47 +0100)
committerThomas Hellström <thomas.hellstrom@linux.intel.com>
Wed, 26 Jan 2022 13:02:31 +0000 (14:02 +0100)
In some cases we use leftover kfree() instead of i915_vma_resource_free().
Fix this.

Fixes: 2f6b90da9192 ("drm/i915: Use vma resources for async unbinding")
Reported-by: Robert Beckett <bob.beckett@collabora.com>
Cc: Matthew Auld <matthew.auld@intel.com>
Signed-off-by: Thomas Hellström <thomas.hellstrom@linux.intel.com>
Reviewed-by: Matthew Auld <matthew.auld@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20220119174734.213552-1-thomas.hellstrom@linux.intel.com
drivers/gpu/drm/i915/i915_vma.c
drivers/gpu/drm/i915/i915_vma_resource.c

index 426ed08b15ad0c3642b0adfe37b151fb24217c2d..cdf1f9066c4f0a05ef1da99cb1d5e2d7f94efa35 100644 (file)
@@ -463,7 +463,7 @@ int i915_vma_bind(struct i915_vma *vma,
        if (vma->resource || !vma_res) {
                /* Rebinding with an additional I915_VMA_*_BIND */
                GEM_WARN_ON(!vma_flags);
-               kfree(vma_res);
+               i915_vma_resource_free(vma_res);
        } else {
                i915_vma_resource_init_from_vma(vma_res, vma);
                vma->resource = vma_res;
@@ -1406,7 +1406,7 @@ err_active:
 err_unlock:
        mutex_unlock(&vma->vm->mutex);
 err_vma_res:
-       kfree(vma_res);
+       i915_vma_resource_free(vma_res);
 err_fence:
        if (work)
                dma_fence_work_commit_imm(&work->base);
index bbb0ff14272fc9ab4f8f5aba91fe621fa2582718..57ae92ba8af1ba4a5318559e280dacd6e48c36b6 100644 (file)
@@ -62,7 +62,8 @@ struct i915_vma_resource *i915_vma_resource_alloc(void)
  */
 void i915_vma_resource_free(struct i915_vma_resource *vma_res)
 {
-       kmem_cache_free(slab_vma_resources, vma_res);
+       if (vma_res)
+               kmem_cache_free(slab_vma_resources, vma_res);
 }
 
 static const char *get_driver_name(struct dma_fence *fence)