omapfb: fix multiple reference count leaks due to pm_runtime_get_sync
authorAditya Pakki <pakki001@umn.edu>
Sun, 14 Jun 2020 03:05:18 +0000 (22:05 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 3 Sep 2020 09:22:26 +0000 (11:22 +0200)
[ Upstream commit 78c2ce9bde70be5be7e3615a2ae7024ed8173087 ]

On calling pm_runtime_get_sync() the reference count of the device
is incremented. In case of failure, decrement the
reference count before returning the error.

Signed-off-by: Aditya Pakki <pakki001@umn.edu>
Cc: kjlu@umn.edu
Cc: wu000273@umn.edu
Cc: Allison Randal <allison@lohutok.net>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Enrico Weigelt <info@metux.net>
cc: "Andrew F. Davis" <afd@ti.com>
Cc: Tomi Valkeinen <tomi.valkeinen@ti.com>
Cc: Alexios Zavras <alexios.zavras@intel.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: YueHaibing <yuehaibing@huawei.com>
Signed-off-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20200614030528.128064-1-pakki001@umn.edu
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/video/fbdev/omap2/omapfb/dss/dispc.c
drivers/video/fbdev/omap2/omapfb/dss/dsi.c
drivers/video/fbdev/omap2/omapfb/dss/dss.c
drivers/video/fbdev/omap2/omapfb/dss/hdmi4.c
drivers/video/fbdev/omap2/omapfb/dss/hdmi5.c
drivers/video/fbdev/omap2/omapfb/dss/venc.c

index 7a75dfda98457c37965412233539bfeab534b265..00f5a54aaf9b7205da9370ec419f9d0a60cb072b 100644 (file)
@@ -531,8 +531,11 @@ int dispc_runtime_get(void)
        DSSDBG("dispc_runtime_get\n");
 
        r = pm_runtime_get_sync(&dispc.pdev->dev);
-       WARN_ON(r < 0);
-       return r < 0 ? r : 0;
+       if (WARN_ON(r < 0)) {
+               pm_runtime_put_sync(&dispc.pdev->dev);
+               return r;
+       }
+       return 0;
 }
 EXPORT_SYMBOL(dispc_runtime_get);
 
index 30d49f3800b334b0a3f6b8ed29ea437d30cb632e..2bfd9063cdfc3de539df4bb704b88a30d647a60c 100644 (file)
@@ -1148,8 +1148,11 @@ static int dsi_runtime_get(struct platform_device *dsidev)
        DSSDBG("dsi_runtime_get\n");
 
        r = pm_runtime_get_sync(&dsi->pdev->dev);
-       WARN_ON(r < 0);
-       return r < 0 ? r : 0;
+       if (WARN_ON(r < 0)) {
+               pm_runtime_put_sync(&dsi->pdev->dev);
+               return r;
+       }
+       return 0;
 }
 
 static void dsi_runtime_put(struct platform_device *dsidev)
index 4429ad37b64cd2e5a5aab4e86c96acea5e22893e..acecee5b1c10296900ea8a91a22f18aea492c059 100644 (file)
@@ -778,8 +778,11 @@ int dss_runtime_get(void)
        DSSDBG("dss_runtime_get\n");
 
        r = pm_runtime_get_sync(&dss.pdev->dev);
-       WARN_ON(r < 0);
-       return r < 0 ? r : 0;
+       if (WARN_ON(r < 0)) {
+               pm_runtime_put_sync(&dss.pdev->dev);
+               return r;
+       }
+       return 0;
 }
 
 void dss_runtime_put(void)
index ec78d61bc55122e3fca807a55f612ba740f077ce..e2d571ca8590aff5d92f4bd79a7f474c9086820e 100644 (file)
@@ -50,9 +50,10 @@ static int hdmi_runtime_get(void)
        DSSDBG("hdmi_runtime_get\n");
 
        r = pm_runtime_get_sync(&hdmi.pdev->dev);
-       WARN_ON(r < 0);
-       if (r < 0)
+       if (WARN_ON(r < 0)) {
+               pm_runtime_put_sync(&hdmi.pdev->dev);
                return r;
+       }
 
        return 0;
 }
index 2e2fcc3d6d4f7b7ade7edcea0bb24463f062f799..13f3a5ce552943f419597b5039d181a55acd8522 100644 (file)
@@ -54,9 +54,10 @@ static int hdmi_runtime_get(void)
        DSSDBG("hdmi_runtime_get\n");
 
        r = pm_runtime_get_sync(&hdmi.pdev->dev);
-       WARN_ON(r < 0);
-       if (r < 0)
+       if (WARN_ON(r < 0)) {
+               pm_runtime_put_sync(&hdmi.pdev->dev);
                return r;
+       }
 
        return 0;
 }
index 392464da12e419ce518d790cd800d46089fd454e..96714b4596d2dbfbddf72bc3f3904a1c99a91e50 100644 (file)
@@ -402,8 +402,11 @@ static int venc_runtime_get(void)
        DSSDBG("venc_runtime_get\n");
 
        r = pm_runtime_get_sync(&venc.pdev->dev);
-       WARN_ON(r < 0);
-       return r < 0 ? r : 0;
+       if (WARN_ON(r < 0)) {
+               pm_runtime_put_sync(&venc.pdev->dev);
+               return r;
+       }
+       return 0;
 }
 
 static void venc_runtime_put(void)