From: Navid Emamdoost <navid.emamdo...@gmail.com>

[ Upstream commit f79f94765f8c39db0b7dec1d335ab046aac03f20 ]

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.emamdo...@gmail.com>
Signed-off-by: Alex Deucher <alexander.deuc...@amd.com>
Signed-off-by: Sasha Levin <sas...@kernel.org>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c
index 1f0e6ede120c4..1b3fda2331bee 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c
@@ -734,8 +734,10 @@ amdgpu_connector_lvds_detect(struct drm_connector 
*connector, bool force)
 
        if (!drm_kms_helper_is_poll_worker()) {
                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;
+               }
        }
 
        if (encoder) {
@@ -863,8 +865,10 @@ amdgpu_connector_vga_detect(struct drm_connector 
*connector, bool force)
 
        if (!drm_kms_helper_is_poll_worker()) {
                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;
+               }
        }
 
        encoder = amdgpu_connector_best_single_encoder(connector);
@@ -986,8 +990,10 @@ amdgpu_connector_dvi_detect(struct drm_connector 
*connector, bool force)
 
        if (!drm_kms_helper_is_poll_worker()) {
                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;
+               }
        }
 
        if (!force && amdgpu_connector_check_hpd_status_unchanged(connector)) {
@@ -1360,8 +1366,10 @@ amdgpu_connector_dp_detect(struct drm_connector 
*connector, bool force)
 
        if (!drm_kms_helper_is_poll_worker()) {
                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;
+               }
        }
 
        if (!force && amdgpu_connector_check_hpd_status_unchanged(connector)) {
-- 
2.25.1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

Reply via email to