2020-06-05 02:47:11

by Navid Emamdoost

[permalink] [raw]
Subject: [PATCH] io: pressure: zpa2326: handle pm_runtime_get_sync failure

Calling pm_runtime_get_sync increments the counter even in case of
failure, causing incorrect ref count. Call pm_runtime_put if
pm_runtime_get_sync fails.

Signed-off-by: Navid Emamdoost <[email protected]>
---
drivers/iio/pressure/zpa2326.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/iio/pressure/zpa2326.c b/drivers/iio/pressure/zpa2326.c
index 99dfe33ee402..245f2e2d412b 100644
--- a/drivers/iio/pressure/zpa2326.c
+++ b/drivers/iio/pressure/zpa2326.c
@@ -664,8 +664,10 @@ static int zpa2326_resume(const struct iio_dev *indio_dev)
int err;

err = pm_runtime_get_sync(indio_dev->dev.parent);
- if (err < 0)
+ if (err < 0) {
+ pm_runtime_put(indio_dev->dev.parent);
return err;
+ }

if (err > 0) {
/*
--
2.17.1


2020-06-06 16:14:22

by Jonathan Cameron

[permalink] [raw]
Subject: Re: [PATCH] io: pressure: zpa2326: handle pm_runtime_get_sync failure

On Thu, 4 Jun 2020 21:44:44 -0500
Navid Emamdoost <[email protected]> wrote:

> Calling pm_runtime_get_sync increments the counter even in case of
> failure, causing incorrect ref count. Call pm_runtime_put if
> pm_runtime_get_sync fails.
>
> Signed-off-by: Navid Emamdoost <[email protected]>

Hi Navid,

This looks to be a fix, be it for a case that we are hopefully
unlikely to ever hit. Please could you add an appropriate
Fixes tag so we can work out how far to backport it?

Patch looks good to me so if you just reply with a suitable
tag I can add it whilst applying.

Thanks,

Jonathan

> ---
> drivers/iio/pressure/zpa2326.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/iio/pressure/zpa2326.c b/drivers/iio/pressure/zpa2326.c
> index 99dfe33ee402..245f2e2d412b 100644
> --- a/drivers/iio/pressure/zpa2326.c
> +++ b/drivers/iio/pressure/zpa2326.c
> @@ -664,8 +664,10 @@ static int zpa2326_resume(const struct iio_dev *indio_dev)
> int err;
>
> err = pm_runtime_get_sync(indio_dev->dev.parent);
> - if (err < 0)
> + if (err < 0) {
> + pm_runtime_put(indio_dev->dev.parent);
> return err;
> + }
>
> if (err > 0) {
> /*

2020-06-08 03:50:22

by Navid Emamdoost

[permalink] [raw]
Subject: Re: [PATCH] io: pressure: zpa2326: handle pm_runtime_get_sync failure

On Sat, Jun 6, 2020 at 2:29 PM Andy Shevchenko
<[email protected]> wrote:
>
>
>
> On Saturday, June 6, 2020, Jonathan Cameron <[email protected]> wrote:
>>
>> On Thu, 4 Jun 2020 21:44:44 -0500
>> Navid Emamdoost <[email protected]> wrote:
>>
>> > Calling pm_runtime_get_sync increments the counter even in case of
>> > failure, causing incorrect ref count. Call pm_runtime_put if
>> > pm_runtime_get_sync fails.
>> >
>> > Signed-off-by: Navid Emamdoost <[email protected]>
>>
>> Hi Navid,
>>
>> This looks to be a fix, be it for a case that we are hopefully
>> unlikely to ever hit. Please could you add an appropriate
>> Fixes tag so we can work out how far to backport it?
>>
>> Patch looks good to me so if you just reply with a suitable
>> tag I can add it whilst applying.

Hi Jonathan,
Here is the fixes tag:

Fixes: 03b262f2bbf4 ("iio:pressure: initial zpa2326 barometer support")

>
>
>
> Should not be "iio: ..." in the prefix?

Yes! It should be "iio" in the patch name.


>>
>>
>> Thanks,
>>
>> Jonathan
>>
>> > ---
>> > drivers/iio/pressure/zpa2326.c | 4 +++-
>> > 1 file changed, 3 insertions(+), 1 deletion(-)
>> >
>> > diff --git a/drivers/iio/pressure/zpa2326.c b/drivers/iio/pressure/zpa2326.c
>> > index 99dfe33ee402..245f2e2d412b 100644
>> > --- a/drivers/iio/pressure/zpa2326.c
>> > +++ b/drivers/iio/pressure/zpa2326.c
>> > @@ -664,8 +664,10 @@ static int zpa2326_resume(const struct iio_dev *indio_dev)
>> > int err;
>> >
>> > err = pm_runtime_get_sync(indio_dev->dev.parent);
>> > - if (err < 0)
>> > + if (err < 0) {
>> > + pm_runtime_put(indio_dev->dev.parent);
>> > return err;
>> > + }
>> >
>> > if (err > 0) {
>> > /*
>>
>
>
> --
> With Best Regards,
> Andy Shevchenko
>
>


--
Navid.