drm/nouveau: Fix reference count leak in nouveau_connector_detect
authorAditya Pakki <pakki001@umn.edu>
Sun, 14 Jun 2020 01:22:23 +0000 (20:22 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 3 Sep 2020 09:22:27 +0000 (11:22 +0200)
[ Upstream commit 990a1162986e8eff7ca18cc5a0e03b4304392ae2 ]

nouveau_connector_detect() calls pm_runtime_get_sync and in turn
increments the reference count. In case of failure, decrement the
ref count before returning the error.

Signed-off-by: Aditya Pakki <pakki001@umn.edu>
Signed-off-by: Ben Skeggs <bskeggs@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/gpu/drm/nouveau/nouveau_connector.c

index 4a7d50a96d36f930ff53c3f8c09635e85fb6578a..b5c8219c54557bc03a13c8e780bf491b8e28292f 100644 (file)
@@ -580,8 +580,10 @@ nouveau_connector_detect(struct drm_connector *connector, bool force)
                pm_runtime_get_noresume(dev->dev);
        } else {
                ret = pm_runtime_get_sync(dev->dev);
-               if (ret < 0 && ret != -EACCES)
+               if (ret < 0 && ret != -EACCES) {
+                       pm_runtime_put_autosuspend(dev->dev);
                        return conn_status;
+               }
        }
 
        nv_encoder = nouveau_connector_ddc_detect(connector);