From: Christian König Date: Mon, 11 Jan 2016 14:35:18 +0000 (+0100) Subject: drm/ttm: fix adding foreign BOs to the LRU during init v2 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=33d48cf8256f2b72e4082a7996c04bf1e78fce81;p=GitHub%2FLineageOS%2Fandroid_kernel_motorola_exynos9610.git drm/ttm: fix adding foreign BOs to the LRU during init v2 If we import a BO with an external reservation object we don't reserve/unreserve it. So we never add it to the LRU causing a possible denial of service. v2: fix typo in commit message Reviewed-by: Thomas Hellstrom Signed-off-by: Christian König Signed-off-by: Alex Deucher --- diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c index 745e996d2dbc..a98a5d5d756d 100644 --- a/drivers/gpu/drm/ttm/ttm_bo.c +++ b/drivers/gpu/drm/ttm/ttm_bo.c @@ -1170,9 +1170,15 @@ int ttm_bo_init(struct ttm_bo_device *bdev, if (likely(!ret)) ret = ttm_bo_validate(bo, placement, interruptible, false); - if (!resv) + if (!resv) { ttm_bo_unreserve(bo); + } else if (!(bo->mem.placement & TTM_PL_FLAG_NO_EVICT)) { + spin_lock(&bo->glob->lru_lock); + ttm_bo_add_to_lru(bo); + spin_unlock(&bo->glob->lru_lock); + } + if (unlikely(ret)) ttm_bo_unref(&bo);