2020-06-14 07:14:03

by Navid Emamdoost

[permalink] [raw]
Subject: [PATCH] drm/amdgpu: fix ref count leak in amdgpu_display_crtc_set_config

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 <[email protected]>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_display.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
index f7143d927b6d..5e51f0acf744 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
@@ -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);

@@ -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 */
@@ -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;
--
2.17.1


2020-06-14 13:09:26

by Markus Elfring

[permalink] [raw]
Subject: Re: [PATCH] drm/amdgpu: fix ref count leak in amdgpu_display_crtc_set_config

> in amdgpu_display_crtc_set_config, …

* Can the term “reference count” become relevant also for this commit message
besides other possible adjustments?

* Can it be nicer to combine proposed updates for this software module
as a patch series (with a cover letter)?

* Would you like to add the tag “Fixes”?



> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c

> @@ -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;

Perhaps use the label “put_runtime” instead?

Regards,
Markus