[PATCH 18/18] oops
Matthew Auld
matthew.auld at intel.com
Wed May 12 15:16:15 UTC 2021
---
drivers/gpu/drm/i915/i915_ttm_buddy_manager.c | 16 ++++++++++++----
1 file changed, 12 insertions(+), 4 deletions(-)
diff --git a/drivers/gpu/drm/i915/i915_ttm_buddy_manager.c b/drivers/gpu/drm/i915/i915_ttm_buddy_manager.c
index 0e6193689e18..e83d9e23b256 100644
--- a/drivers/gpu/drm/i915/i915_ttm_buddy_manager.c
+++ b/drivers/gpu/drm/i915/i915_ttm_buddy_manager.c
@@ -32,9 +32,9 @@ static int i915_ttm_buddy_man_alloc(struct ttm_resource_manager *man,
{
struct i915_ttm_buddy_manager *bman = to_buddy_manager(man);
struct i915_buddy_mm *mm = &bman->mm;
+ struct list_head *blocks;
unsigned long n_pages;
unsigned int min_order;
- LIST_HEAD(blocks);
u64 size;
GEM_BUG_ON(place->fpfn || place->lpfn);
@@ -52,6 +52,12 @@ static int i915_ttm_buddy_man_alloc(struct ttm_resource_manager *man,
if (size > mm->size)
return -E2BIG;
+ blocks = kmalloc(sizeof(struct list_head), GFP_KERNEL);
+ if (!blocks)
+ return -ENOMEM;
+
+ INIT_LIST_HEAD(blocks);
+
n_pages = size >> ilog2(mm->chunk_size);
mutex_lock(&bman->lock);
@@ -76,7 +82,7 @@ static int i915_ttm_buddy_man_alloc(struct ttm_resource_manager *man,
n_pages -= BIT(order);
block->private = mm; /* XXX */
- list_add_tail(&block->link, &blocks);
+ list_add_tail(&block->link, blocks);
if (!n_pages)
break;
@@ -84,13 +90,14 @@ static int i915_ttm_buddy_man_alloc(struct ttm_resource_manager *man,
mutex_unlock(&bman->lock);
- mem->mm_node = &blocks;
+ mem->mm_node = blocks;
mem->start = 0; /* XXX: do we need this? */
return 0;
err_free_blocks:
- i915_buddy_free_list(mm, &blocks);
+ i915_buddy_free_list(mm, blocks);
mutex_unlock(&bman->lock);
+ kfree(blocks);
return -ENXIO;
}
@@ -106,6 +113,7 @@ static void i915_ttm_buddy_man_free(struct ttm_resource_manager *man,
i915_buddy_free_list(&bman->mm, blocks);
mutex_unlock(&bman->lock);
+ kfree(blocks);
mem->mm_node = NULL;
}
}
--
2.26.3
More information about the Intel-gfx-trybot
mailing list