Commit f79f9476 authored by Navid Emamdoost's avatar Navid Emamdoost Committed by Alex Deucher

drm/amdgpu/display: fix ref count leak when pm_runtime_get_sync fails

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: default avatarNavid Emamdoost <navid.emamdoost@gmail.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent e008fa6f
...@@ -716,9 +716,11 @@ amdgpu_connector_lvds_detect(struct drm_connector *connector, bool force) ...@@ -716,9 +716,11 @@ amdgpu_connector_lvds_detect(struct drm_connector *connector, bool force)
if (!drm_kms_helper_is_poll_worker()) { if (!drm_kms_helper_is_poll_worker()) {
r = pm_runtime_get_sync(connector->dev->dev); r = pm_runtime_get_sync(connector->dev->dev);
if (r < 0) if (r < 0) {
pm_runtime_put_autosuspend(connector->dev->dev);
return connector_status_disconnected; return connector_status_disconnected;
} }
}
if (encoder) { if (encoder) {
struct amdgpu_encoder *amdgpu_encoder = to_amdgpu_encoder(encoder); struct amdgpu_encoder *amdgpu_encoder = to_amdgpu_encoder(encoder);
...@@ -854,9 +856,11 @@ amdgpu_connector_vga_detect(struct drm_connector *connector, bool force) ...@@ -854,9 +856,11 @@ amdgpu_connector_vga_detect(struct drm_connector *connector, bool force)
if (!drm_kms_helper_is_poll_worker()) { if (!drm_kms_helper_is_poll_worker()) {
r = pm_runtime_get_sync(connector->dev->dev); r = pm_runtime_get_sync(connector->dev->dev);
if (r < 0) if (r < 0) {
pm_runtime_put_autosuspend(connector->dev->dev);
return connector_status_disconnected; return connector_status_disconnected;
} }
}
encoder = amdgpu_connector_best_single_encoder(connector); encoder = amdgpu_connector_best_single_encoder(connector);
if (!encoder) if (!encoder)
...@@ -977,9 +981,11 @@ amdgpu_connector_dvi_detect(struct drm_connector *connector, bool force) ...@@ -977,9 +981,11 @@ amdgpu_connector_dvi_detect(struct drm_connector *connector, bool force)
if (!drm_kms_helper_is_poll_worker()) { if (!drm_kms_helper_is_poll_worker()) {
r = pm_runtime_get_sync(connector->dev->dev); r = pm_runtime_get_sync(connector->dev->dev);
if (r < 0) if (r < 0) {
pm_runtime_put_autosuspend(connector->dev->dev);
return connector_status_disconnected; return connector_status_disconnected;
} }
}
if (!force && amdgpu_connector_check_hpd_status_unchanged(connector)) { if (!force && amdgpu_connector_check_hpd_status_unchanged(connector)) {
ret = connector->status; ret = connector->status;
...@@ -1328,9 +1334,11 @@ amdgpu_connector_dp_detect(struct drm_connector *connector, bool force) ...@@ -1328,9 +1334,11 @@ amdgpu_connector_dp_detect(struct drm_connector *connector, bool force)
if (!drm_kms_helper_is_poll_worker()) { if (!drm_kms_helper_is_poll_worker()) {
r = pm_runtime_get_sync(connector->dev->dev); r = pm_runtime_get_sync(connector->dev->dev);
if (r < 0) if (r < 0) {
pm_runtime_put_autosuspend(connector->dev->dev);
return connector_status_disconnected; return connector_status_disconnected;
} }
}
if (!force && amdgpu_connector_check_hpd_status_unchanged(connector)) { if (!force && amdgpu_connector_check_hpd_status_unchanged(connector)) {
ret = connector->status; ret = connector->status;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment