Re: [PATCH] iio: light: gp2ap002: Fix rumtime PM imbalance on error

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed,  7 Apr 2021 11:49:27 +0800
Dinghao Liu <dinghao.liu@xxxxxxxxxx> wrote:

> When devm_request_threaded_irq() fails, we should decrease the
> runtime PM counter to keep the counter balanced. But when
> iio_device_register() fails, we need not to decrease it because
> we have already decreased it before.

Whilst agree with your assessment that the code is wrong, I'm not
totally sure why we need to do the pm_runtime_get_noresume() in
the first place.   Why do we need to hold the reference for
the operations going on here?  What can race against this that
might care about that reference count?

Jonathan


> 
> Signed-off-by: Dinghao Liu <dinghao.liu@xxxxxxxxxx>
> ---
>  drivers/iio/light/gp2ap002.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/iio/light/gp2ap002.c b/drivers/iio/light/gp2ap002.c
> index 7ba7aa59437c..040d8429a6e0 100644
> --- a/drivers/iio/light/gp2ap002.c
> +++ b/drivers/iio/light/gp2ap002.c
> @@ -583,7 +583,7 @@ static int gp2ap002_probe(struct i2c_client *client,
>  					"gp2ap002", indio_dev);
>  	if (ret) {
>  		dev_err(dev, "unable to request IRQ\n");
> -		goto out_disable_vio;
> +		goto out_put_pm;
>  	}
>  	gp2ap002->irq = client->irq;
>  
> @@ -613,8 +613,9 @@ static int gp2ap002_probe(struct i2c_client *client,
>  
>  	return 0;
>  
> -out_disable_pm:
> +out_put_pm:
>  	pm_runtime_put_noidle(dev);
> +out_disable_pm:
>  	pm_runtime_disable(dev);
>  out_disable_vio:
>  	regulator_disable(gp2ap002->vio);




[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Input]     [Linux Kernel]     [Linux SCSI]     [X.org]

  Powered by Linux