Skip to content

Commit

Permalink
drm/amdgpu: fix ref count leak in amdgpu_display_crtc_set_config
Browse files Browse the repository at this point in the history
[ Upstream commit e008fa6 ]

in amdgpu_display_crtc_set_config, 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.

Signed-off-by: Navid Emamdoost <navid.emamdoost@gmail.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
Navidem authored and gregkh committed Sep 3, 2020
1 parent c04caca commit b86657e
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
Expand Up @@ -282,7 +282,7 @@ int amdgpu_display_crtc_set_config(struct drm_mode_set *set,

ret = pm_runtime_get_sync(dev->dev);
if (ret < 0)
return ret;
goto out;

ret = drm_crtc_helper_set_config(set, ctx);

Expand All @@ -297,7 +297,7 @@ int amdgpu_display_crtc_set_config(struct drm_mode_set *set,
take the current one */
if (active && !adev->have_disp_power_ref) {
adev->have_disp_power_ref = true;
return ret;
goto out;
}
/* if we have no active crtcs, then drop the power ref
we got before */
Expand All @@ -306,6 +306,7 @@ int amdgpu_display_crtc_set_config(struct drm_mode_set *set,
adev->have_disp_power_ref = false;
}

out:
/* drop the power reference we got coming in here */
pm_runtime_put_autosuspend(dev->dev);
return ret;
Expand Down

0 comments on commit b86657e

Please sign in to comment.