2021-04-12 06:01:46

by Dinghao Liu

[permalink] [raw]
Subject: [PATCH] [v2] usb: cdns3: Fix runtime PM imbalance on error

When cdns3_gadget_start() fails, a pairing PM usage counter
decrement is needed to keep the counter balanced.

Signed-off-by: Dinghao Liu <[email protected]>
---

Changelog:

v2: - Use pm_runtime_put_sync() to decrease refcount.
---
drivers/usb/cdns3/cdns3-gadget.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/cdns3/cdns3-gadget.c b/drivers/usb/cdns3/cdns3-gadget.c
index 582bfeceedb4..a49fc68ec2ef 100644
--- a/drivers/usb/cdns3/cdns3-gadget.c
+++ b/drivers/usb/cdns3/cdns3-gadget.c
@@ -3255,8 +3255,10 @@ static int __cdns3_gadget_init(struct cdns *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
--
2.17.1


2021-04-19 03:58:40

by Peter Chen

[permalink] [raw]
Subject: Re: [PATCH] [v2] usb: cdns3: Fix runtime PM imbalance on error

On 21-04-12 13:49:07, Dinghao Liu wrote:
> When cdns3_gadget_start() fails, a pairing PM usage counter
> decrement is needed to keep the counter balanced.
>
> Signed-off-by: Dinghao Liu <[email protected]>

Applied, thanks.

Peter
> ---
>
> Changelog:
>
> v2: - Use pm_runtime_put_sync() to decrease refcount.
> ---
> drivers/usb/cdns3/cdns3-gadget.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/usb/cdns3/cdns3-gadget.c b/drivers/usb/cdns3/cdns3-gadget.c
> index 582bfeceedb4..a49fc68ec2ef 100644
> --- a/drivers/usb/cdns3/cdns3-gadget.c
> +++ b/drivers/usb/cdns3/cdns3-gadget.c
> @@ -3255,8 +3255,10 @@ static int __cdns3_gadget_init(struct cdns *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
> --
> 2.17.1
>

--

Thanks,
Peter Chen