diff options
author | Christian König <christian.koenig@amd.com> | 2021-05-28 14:34:38 +0200 |
---|---|---|
committer | Christian König <christian.koenig@amd.com> | 2021-06-08 13:24:15 +0200 |
commit | 2d2ddb589d5925ec7f2d1b17d88a2b36bf536105 (patch) | |
tree | 26f8bb253815fb1dad99a683f45f2f27c2daa882 /drivers/gpu/drm/ttm/ttm_device.c | |
parent | 9bf3797796f570b34438235a6a537df85832bdad (diff) | |
download | linux-2d2ddb589d5925ec7f2d1b17d88a2b36bf536105.tar.gz linux-2d2ddb589d5925ec7f2d1b17d88a2b36bf536105.tar.bz2 linux-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_device.c')
-rw-r--r-- | drivers/gpu/drm/ttm/ttm_device.c | 8 |
1 files changed, 1 insertions, 7 deletions
diff --git a/drivers/gpu/drm/ttm/ttm_device.c b/drivers/gpu/drm/ttm/ttm_device.c index a1dcf7d55c90..3d9c62b93e29 100644 --- a/drivers/gpu/drm/ttm/ttm_device.c +++ b/drivers/gpu/drm/ttm/ttm_device.c @@ -143,14 +143,8 @@ int ttm_device_swapout(struct ttm_device *bdev, struct ttm_operation_ctx *ctx, for (j = 0; j < TTM_MAX_BO_PRIORITY; ++j) { list_for_each_entry(bo, &man->lru[j], lru) { - uint32_t num_pages; + uint32_t num_pages = PFN_UP(bo->base.size); - 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) - continue; - - num_pages = bo->ttm->num_pages; ret = ttm_bo_swapout(bo, ctx, gfp_flags); /* ttm_bo_swapout has dropped the lru_lock */ if (!ret) |