]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/commitdiff
drm/amd/amdgpu/amdgpu_cs: fix refcount leak of a dma_fence obj
authorXin Xiong <xiongx18@fudan.edu.cn>
Fri, 21 Jan 2022 20:46:23 +0000 (15:46 -0500)
committerStefan Bader <stefan.bader@canonical.com>
Fri, 20 May 2022 13:19:42 +0000 (15:19 +0200)
BugLink: https://bugs.launchpad.net/bugs/1971497
[ Upstream commit dfced44f122c500004a48ecc8db516bb6a295a1b ]

This issue takes place in an error path in
amdgpu_cs_fence_to_handle_ioctl(). When `info->in.what` falls into
default case, the function simply returns -EINVAL, forgetting to
decrement the reference count of a dma_fence obj, which is bumped
earlier by amdgpu_cs_get_fence(). This may result in reference count
leaks.

Fix it by decreasing the refcount of specific object before returning
the error code.

Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Xin Xiong <xiongx18@fudan.edu.cn>
Signed-off-by: Xin Tan <tanxin.ctf@gmail.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c

index 82823d9a8ba8874e33959ef389465210a91f46f2..fddeea2b17e50a87aa89f08f8e55cdc00221b70e 100644 (file)
@@ -1542,6 +1542,7 @@ int amdgpu_cs_fence_to_handle_ioctl(struct drm_device *dev, void *data,
                return 0;
 
        default:
+               dma_fence_put(fence);
                return -EINVAL;
        }
 }