summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/ttm/ttm_bo.c
diff options
context:
space:
mode:
authorChristian König <christian.koenig@amd.com>2021-05-28 14:34:38 +0200
committerChristian König <christian.koenig@amd.com>2021-06-08 13:24:15 +0200
commit2d2ddb589d5925ec7f2d1b17d88a2b36bf536105 (patch)
tree26f8bb253815fb1dad99a683f45f2f27c2daa882 /drivers/gpu/drm/ttm/ttm_bo.c
parent9bf3797796f570b34438235a6a537df85832bdad (diff)
downloadlinux-stable-2d2ddb589d5925ec7f2d1b17d88a2b36bf536105.tar.gz
linux-stable-2d2ddb589d5925ec7f2d1b17d88a2b36bf536105.tar.bz2
linux-stable-2d2ddb589d5925ec7f2d1b17d88a2b36bf536105.zip
drm/ttm: fix deref of bo->ttm without holding the lock v2
We need to grab the resv lock first before doing that check. v2 (chk): simplify the change for -fixes Signed-off-by: Christian König <christian.koenig@amd.com> Signed-off-by: Thomas Hellström <thomas.hellstrom@linux.intel.com> Reviewed-by: Huang Rui <ray.huang@amd.com> Link: https://patchwork.freedesktop.org/patch/msgid/20210528130041.1683-1-christian.koenig@amd.com
Diffstat (limited to 'drivers/gpu/drm/ttm/ttm_bo.c')
-rw-r--r--drivers/gpu/drm/ttm/ttm_bo.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
index cfd0b9292397..ebcffe794adb 100644
--- a/drivers/gpu/drm/ttm/ttm_bo.c
+++ b/drivers/gpu/drm/ttm/ttm_bo.c
@@ -1172,7 +1172,10 @@ int ttm_bo_swapout(struct ttm_buffer_object *bo, struct ttm_operation_ctx *ctx,
if (!ttm_bo_evict_swapout_allowable(bo, ctx, &locked, NULL))
return -EBUSY;
- if (!ttm_bo_get_unless_zero(bo)) {
+ if (!bo->ttm || !ttm_tt_is_populated(bo->ttm) ||
+ bo->ttm->page_flags & TTM_PAGE_FLAG_SG ||
+ bo->ttm->page_flags & TTM_PAGE_FLAG_SWAPPED ||
+ !ttm_bo_get_unless_zero(bo)) {
if (locked)
dma_resv_unlock(bo->base.resv);
return -EBUSY;