All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] extcon: arizona: Fix runtime PM imbalance on error
@ 2020-05-22 11:07 Dinghao Liu
  2020-05-22 16:55 ` Charles Keepax
  0 siblings, 1 reply; 3+ messages in thread
From: Dinghao Liu @ 2020-05-22 11:07 UTC (permalink / raw)
  To: dinghao.liu, kjlu; +Cc: MyungJoo Ham, Chanwoo Choi, patches, linux-kernel

When arizona_request_irq() returns an error code, a
pairing runtime PM usage counter decrement is needed
to keep the counter balanced. For error paths after
this function, things are the same.

Signed-off-by: Dinghao Liu <dinghao.liu@zju.edu.cn>
---
 drivers/extcon/extcon-arizona.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/extcon/extcon-arizona.c b/drivers/extcon/extcon-arizona.c
index 7401733db08b..470bbc8e5089 100644
--- a/drivers/extcon/extcon-arizona.c
+++ b/drivers/extcon/extcon-arizona.c
@@ -1744,6 +1744,7 @@ static int arizona_extcon_probe(struct platform_device *pdev)
 err_rise:
 	arizona_free_irq(arizona, jack_irq_rise, info);
 err_gpio:
+	pm_runtime_put(&pdev->dev);
 	gpiod_put(info->micd_pol_gpio);
 err_register:
 	pm_runtime_disable(&pdev->dev);
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] extcon: arizona: Fix runtime PM imbalance on error
  2020-05-22 11:07 [PATCH] extcon: arizona: Fix runtime PM imbalance on error Dinghao Liu
@ 2020-05-22 16:55 ` Charles Keepax
  2020-05-23  2:51   ` dinghao.liu
  0 siblings, 1 reply; 3+ messages in thread
From: Charles Keepax @ 2020-05-22 16:55 UTC (permalink / raw)
  To: Dinghao Liu; +Cc: kjlu, MyungJoo Ham, Chanwoo Choi, patches, linux-kernel

On Fri, May 22, 2020 at 07:07:31PM +0800, Dinghao Liu wrote:
> When arizona_request_irq() returns an error code, a
> pairing runtime PM usage counter decrement is needed
> to keep the counter balanced. For error paths after
> this function, things are the same.
> 
> Signed-off-by: Dinghao Liu <dinghao.liu@zju.edu.cn>
> ---

Good spot on the bug thank you.

>  drivers/extcon/extcon-arizona.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/extcon/extcon-arizona.c b/drivers/extcon/extcon-arizona.c
> index 7401733db08b..470bbc8e5089 100644
> --- a/drivers/extcon/extcon-arizona.c
> +++ b/drivers/extcon/extcon-arizona.c
> @@ -1744,6 +1744,7 @@ static int arizona_extcon_probe(struct platform_device *pdev)
>  err_rise:
>  	arizona_free_irq(arizona, jack_irq_rise, info);
>  err_gpio:
> +	pm_runtime_put(&pdev->dev);

However, I don't think this works as a fix. Firstly, the err_gpio
label is used before the call to pm_runtime_get_sync, this might
be ok since pm_runtime_enable hasn't been called yet but probably
better to add a new label for it.

Secondly, following the err_hpdet error path will also result in
a double put. In that case I don't think there is any reason why
we need to put before calling input_device_register so it might
just be simplest to move that put until after registering the
input device.

Thanks,
Charles

>  	gpiod_put(info->micd_pol_gpio);
>  err_register:
>  	pm_runtime_disable(&pdev->dev);
> -- 
> 2.17.1
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Re: [PATCH] extcon: arizona: Fix runtime PM imbalance on error
  2020-05-22 16:55 ` Charles Keepax
@ 2020-05-23  2:51   ` dinghao.liu
  0 siblings, 0 replies; 3+ messages in thread
From: dinghao.liu @ 2020-05-23  2:51 UTC (permalink / raw)
  To: Charles Keepax; +Cc: kjlu, MyungJoo Ham, Chanwoo Choi, patches, linux-kernel

> On Fri, May 22, 2020 at 07:07:31PM +0800, Dinghao Liu wrote:
> > When arizona_request_irq() returns an error code, a
> > pairing runtime PM usage counter decrement is needed
> > to keep the counter balanced. For error paths after
> > this function, things are the same.
> > 
> > Signed-off-by: Dinghao Liu <dinghao.liu@zju.edu.cn>
> > ---
> 
> Good spot on the bug thank you.
> 
> >  drivers/extcon/extcon-arizona.c | 1 +
> >  1 file changed, 1 insertion(+)
> > 
> > diff --git a/drivers/extcon/extcon-arizona.c b/drivers/extcon/extcon-arizona.c
> > index 7401733db08b..470bbc8e5089 100644
> > --- a/drivers/extcon/extcon-arizona.c
> > +++ b/drivers/extcon/extcon-arizona.c
> > @@ -1744,6 +1744,7 @@ static int arizona_extcon_probe(struct platform_device *pdev)
> >  err_rise:
> >  	arizona_free_irq(arizona, jack_irq_rise, info);
> >  err_gpio:
> > +	pm_runtime_put(&pdev->dev);
> 
> However, I don't think this works as a fix. Firstly, the err_gpio
> label is used before the call to pm_runtime_get_sync, this might
> be ok since pm_runtime_enable hasn't been called yet but probably
> better to add a new label for it.
> 

You are right, thank you for your correction! 

> Secondly, following the err_hpdet error path will also result in
> a double put. In that case I don't think there is any reason why
> we need to put before calling input_device_register so it might
> just be simplest to move that put until after registering the
> input device.
> 

Agree. I will fix this in the next edition of patch.

Regards,
Dinghao

> Thanks,
> Charles
> 
> >  	gpiod_put(info->micd_pol_gpio);
> >  err_register:
> >  	pm_runtime_disable(&pdev->dev);
> > -- 
> > 2.17.1
> > 

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-05-23  2:51 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-22 11:07 [PATCH] extcon: arizona: Fix runtime PM imbalance on error Dinghao Liu
2020-05-22 16:55 ` Charles Keepax
2020-05-23  2:51   ` dinghao.liu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.