]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
drm/amdgpu/ttm: Fix memory leak userptr pages
authorDaniel Gomez <daniel@qtec.com>
Wed, 17 Mar 2021 16:08:37 +0000 (17:08 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 12 May 2021 06:37:27 +0000 (08:37 +0200)
[ Upstream commit 0f6f9dd490d524930081a6ef1d60171ce39220b9 ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c

index 8b87991a0470adead8165f6c5b61abb2abd1ed54..c074a81e8fae00cf86511fa0e96a5ebea0bc9cfa 100644 (file)
@@ -1163,13 +1163,13 @@ static void amdgpu_ttm_backend_unbind(struct ttm_bo_device *bdev,
        struct amdgpu_ttm_tt *gtt = (void *)ttm;
        int r;
 
-       if (!gtt->bound)
-               return;
-
        /* if the pages have userptr pinning then clear that first */
        if (gtt->userptr)
                amdgpu_ttm_tt_unpin_userptr(bdev, ttm);
 
+       if (!gtt->bound)
+               return;
+
        if (gtt->offset == AMDGPU_BO_INVALID_OFFSET)
                return;