]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
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:26:45 +0000 (11:26 +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 376ee5bc3ddc955e38167b1eb70af0854e569c19..34e8171856e95b69e6dfba886acbd0542cac5924 100644 (file)
@@ -520,8 +520,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 d620376216e1d2d8bc0fc011dca92f5b3101c991..6f9c25fec994694495ef666360b7090acc3252aa 100644 (file)
@@ -1137,8 +1137,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 bfc5c4c5a26adbd254c9256354ae3b34d7210453..a6b1c1598040d9789b2351103d3c0bf7fe10983a 100644 (file)
@@ -768,8 +768,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 7060ae56c062cb7d1f284f5cd424ae6a5eb73c7f..4804aab34298120275ca932cce4b85fadaba993e 100644 (file)
@@ -39,9 +39,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 ac49531e473275c6e25d668adc69af42b6584cc9..a06b6f1355bdbf41603e7a7400df32ee808cb068 100644 (file)
@@ -43,9 +43,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 f81e2a46366dda0aaccae8bc831fafcc43e3efd4..3717dac3dcc83596ea71f8451522e6042362b2e2 100644 (file)
@@ -391,8 +391,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)