drm/amdgpu/fence: fix ref count leak when pm_runtime_get_sync fails
authorAlex Deucher <alexander.deucher@amd.com>
Wed, 17 Jun 2020 18:50:02 +0000 (14:50 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 3 Sep 2020 09:29:17 +0000 (11:29 +0200)
commit2e91283fdb45ffefec70112db98f5bb5619125e1
treef1d3b2f1cc4cecff45425d35f27fc9d8eb401f2b
parente4fdcdb7837c14bf03a8fca2b2e7d3c4ff246d8c
drm/amdgpu/fence: fix ref count leak when pm_runtime_get_sync fails

[ Upstream commit e520d3e0d2818aafcdf9d8b60916754d8fedc366 ]

The call to pm_runtime_get_sync increments the counter even in case of
failure, leading to incorrect ref count.
In case of failure, decrement the ref count before returning.

Reviewed-by: Felix Kuehling <Felix.Kuehling@amd.com>
Acked-by: Rajneesh Bhardwaj <rajneesh.bhardwaj@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c