From: "monk.liu" <monk.liu@xxxxxxx> Fixing a memory leak with userptrs. Signed-off-by: monk.liu <monk.liu@xxxxxxx> Signed-off-by: Christian König <christian.koenig@xxxxxxx> CC: stable@xxxxxxxxxxxxxxx --- drivers/gpu/drm/radeon/radeon_ttm.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon/radeon_ttm.c index b292aca..e661841 100644 --- a/drivers/gpu/drm/radeon/radeon_ttm.c +++ b/drivers/gpu/drm/radeon/radeon_ttm.c @@ -606,13 +606,18 @@ static void radeon_ttm_tt_unpin_userptr(struct ttm_tt *ttm) dma_unmap_sg(rdev->dev, ttm->sg->sgl, ttm->sg->nents, direction); for_each_sg(ttm->sg->sgl, sg, ttm->sg->nents, i) { + int len = sg->length >> PAGE_SHIFT; struct page *page = sg_page(sg); + while (len > 0) { + if (!(gtt->userflags & RADEON_GEM_USERPTR_READONLY)) + set_page_dirty(page); - if (!(gtt->userflags & RADEON_GEM_USERPTR_READONLY)) - set_page_dirty(page); + mark_page_accessed(page); + page_cache_release(page); - mark_page_accessed(page); - page_cache_release(page); + page++; + len--; + } } sg_free_table(ttm->sg); -- 1.9.1 _______________________________________________ dri-devel mailing list dri-devel@xxxxxxxxxxxxxxxxxxxxx http://lists.freedesktop.org/mailman/listinfo/dri-devel