public inbox for stable@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/ttm: Fix an invalid freeing on already freed page in error path
@ 2024-02-21  7:33 Thomas Hellström
  2024-02-21  9:21 ` Matthew Auld
  2024-02-21 10:26 ` Christian König
  0 siblings, 2 replies; 6+ messages in thread
From: Thomas Hellström @ 2024-02-21  7:33 UTC (permalink / raw)
  To: intel-xe, intel-gfx
  Cc: Thomas Hellström, Christian König, Dave Airlie,
	Huang Rui, dri-devel, stable

If caching mode change fails due to, for example, OOM we
free the allocated pages in a two-step process. First the pages
for which the caching change has already succeeded. Secondly
the pages for which a caching change did not succeed.

However the second step was incorrectly freeing the pages already
freed in the first step.

Fix.

Signed-off-by: Thomas Hellström <thomas.hellstrom@linux.intel.com>
Fixes: 379989e7cbdc ("drm/ttm/pool: Fix ttm_pool_alloc error path")
Cc: Christian König <christian.koenig@amd.com>
Cc: Dave Airlie <airlied@redhat.com>
Cc: Christian Koenig <christian.koenig@amd.com>
Cc: Huang Rui <ray.huang@amd.com>
Cc: dri-devel@lists.freedesktop.org
Cc: <stable@vger.kernel.org> # v6.4+
---
 drivers/gpu/drm/ttm/ttm_pool.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/ttm/ttm_pool.c b/drivers/gpu/drm/ttm/ttm_pool.c
index b62f420a9f96..112438d965ff 100644
--- a/drivers/gpu/drm/ttm/ttm_pool.c
+++ b/drivers/gpu/drm/ttm/ttm_pool.c
@@ -387,7 +387,7 @@ static void ttm_pool_free_range(struct ttm_pool *pool, struct ttm_tt *tt,
 				enum ttm_caching caching,
 				pgoff_t start_page, pgoff_t end_page)
 {
-	struct page **pages = tt->pages;
+	struct page **pages = &tt->pages[start_page];
 	unsigned int order;
 	pgoff_t i, nr;
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2024-02-22  9:48 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-02-21  7:33 [PATCH] drm/ttm: Fix an invalid freeing on already freed page in error path Thomas Hellström
2024-02-21  9:21 ` Matthew Auld
2024-02-21 10:26 ` Christian König
2024-02-22  7:34   ` Thomas Hellström
2024-02-22  8:33     ` Thomas Hellström
2024-02-22  9:47     ` Christian König

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox