drm/radeon/ttm: Fix memory leak userptr pages
authorDaniel Gomez <daniel@qtec.com>
Thu, 18 Mar 2021 08:32:36 +0000 (09:32 +0100)
committerAlex Deucher <alexander.deucher@amd.com>
Fri, 9 Apr 2021 20:37:39 +0000 (16:37 -0400)
If userptr pages have been pinned but not bounded,
they remain uncleared.

Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Daniel Gomez <daniel@qtec.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/radeon/radeon_ttm.c

index 476ce9c24b9f50e0ea09d58dae009a5ea94e7bc8..c84e128daff87c2b6c6ac3fa3c20a9f961abdf2f 100644 (file)
@@ -481,13 +481,14 @@ static void radeon_ttm_backend_unbind(struct ttm_device *bdev, struct ttm_tt *tt
        struct radeon_ttm_tt *gtt = (void *)ttm;
        struct radeon_device *rdev = radeon_get_rdev(bdev);
 
+       if (gtt->userptr)
+               radeon_ttm_tt_unpin_userptr(bdev, ttm);
+
        if (!gtt->bound)
                return;
 
        radeon_gart_unbind(rdev, gtt->offset, ttm->num_pages);
 
-       if (gtt->userptr)
-               radeon_ttm_tt_unpin_userptr(bdev, ttm);
        gtt->bound = false;
 }