]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
usb: cdns3: Fix runtime PM imbalance on error
authorDinghao Liu <dinghao.liu@zju.edu.cn>
Mon, 12 Apr 2021 05:49:07 +0000 (13:49 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 16 Jun 2021 09:59:33 +0000 (11:59 +0200)
[ Upstream commit e5b913496099527abe46e175e5e2c844367bded0 ]

pm_runtime_get_sync() increments the runtime PM usage counter even
when it returns an error code. Thus a pairing decrement is needed on
the error handling path to keep the counter balanced.

Reviewed-by: Peter Chen <peter.chen@nxp.com>
Signed-off-by: Dinghao Liu <dinghao.liu@zju.edu.cn>
Signed-off-by: Felipe Balbi <balbi@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/usb/cdns3/gadget.c

index c0c39cf303871497958a525f8f84c71543aa6dc9..f32f00c495713c29c8d2492771e1f3f499a994f1 100644 (file)
@@ -2706,8 +2706,10 @@ static int __cdns3_gadget_init(struct cdns3 *cdns)
        pm_runtime_get_sync(cdns->dev);
 
        ret = cdns3_gadget_start(cdns);
-       if (ret)
+       if (ret) {
+               pm_runtime_put_sync(cdns->dev);
                return ret;
+       }
 
        /*
         * Because interrupt line can be shared with other components in