mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-19 00:55:18 +00:00
drm/ttm: fix invalid NULL deref
The BO might be NULL in this function, use the bdev directly.
Signed-off-by: Christian König <christian.koenig@amd.com>
Reported-by: Colin Ian King <colin.king@canonical.com>
Reviewed-by: Colin Ian King <colin.king@canonical.com>
Fixes: a1f091f8ef
("drm/ttm: switch to per device LRU lock")
Link: https://patchwork.freedesktop.org/patch/msgid/20210325152740.82633-1-christian.koenig@amd.com
This commit is contained in:
parent
30e2ae943c
commit
58442f0db3
1 changed files with 3 additions and 3 deletions
|
@ -625,7 +625,7 @@ int ttm_mem_evict_first(struct ttm_device *bdev,
|
||||||
unsigned i;
|
unsigned i;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
spin_lock(&bo->bdev->lru_lock);
|
spin_lock(&bdev->lru_lock);
|
||||||
for (i = 0; i < TTM_MAX_BO_PRIORITY; ++i) {
|
for (i = 0; i < TTM_MAX_BO_PRIORITY; ++i) {
|
||||||
list_for_each_entry(bo, &man->lru[i], lru) {
|
list_for_each_entry(bo, &man->lru[i], lru) {
|
||||||
bool busy;
|
bool busy;
|
||||||
|
@ -662,7 +662,7 @@ int ttm_mem_evict_first(struct ttm_device *bdev,
|
||||||
if (!bo) {
|
if (!bo) {
|
||||||
if (busy_bo && !ttm_bo_get_unless_zero(busy_bo))
|
if (busy_bo && !ttm_bo_get_unless_zero(busy_bo))
|
||||||
busy_bo = NULL;
|
busy_bo = NULL;
|
||||||
spin_unlock(&bo->bdev->lru_lock);
|
spin_unlock(&bdev->lru_lock);
|
||||||
ret = ttm_mem_evict_wait_busy(busy_bo, ctx, ticket);
|
ret = ttm_mem_evict_wait_busy(busy_bo, ctx, ticket);
|
||||||
if (busy_bo)
|
if (busy_bo)
|
||||||
ttm_bo_put(busy_bo);
|
ttm_bo_put(busy_bo);
|
||||||
|
@ -676,7 +676,7 @@ int ttm_mem_evict_first(struct ttm_device *bdev,
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
spin_unlock(&bo->bdev->lru_lock);
|
spin_unlock(&bdev->lru_lock);
|
||||||
|
|
||||||
ret = ttm_bo_evict(bo, ctx);
|
ret = ttm_bo_evict(bo, ctx);
|
||||||
if (locked)
|
if (locked)
|
||||||
|
|
Loading…
Reference in a new issue