Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit fd5002d6 authored by Felix Kuehling's avatar Felix Kuehling Committed by Alex Deucher
Browse files

drm/ttm: Don't add swapped BOs to swap-LRU list



A BO that's already swapped would be added back to the swap-LRU list
for example if its validation failed under high memory pressure. This
could later lead to swapping it out again and leaking previous swap
storage.

This commit adds a condition to prevent that from happening.

v2: Check page_flags instead of swap_storage

Signed-off-by: default avatarFelix Kuehling <Felix.Kuehling@amd.com>
Reviewed-by: default avatarChristian König <christian.koenig@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
Cc: stable@vger.kernel.org
parent 5ba4fa35
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -170,7 +170,8 @@ void ttm_bo_add_to_lru(struct ttm_buffer_object *bo)
		list_add_tail(&bo->lru, &man->lru[bo->priority]);
		kref_get(&bo->list_kref);

		if (bo->ttm && !(bo->ttm->page_flags & TTM_PAGE_FLAG_SG)) {
		if (bo->ttm && !(bo->ttm->page_flags &
				 (TTM_PAGE_FLAG_SG | TTM_PAGE_FLAG_SWAPPED))) {
			list_add_tail(&bo->swap,
				      &bo->glob->swap_lru[bo->priority]);
			kref_get(&bo->list_kref);