Re: [PATCH -next] iio: adc: sun4i-gpadc-iio: fix PM disable depth imbalance in sun4i_gpadc_probe

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

 



On Mon, 26 Sep 2022 23:02:06 +0800
Zhang Qilong <zhangqilong3@xxxxxxxxxx> wrote:

> The pm_runtime_enable will increase power disable depth. Thus
> a pairing decrement is needed on the error handling path to
> keep it balanced according to context.
> 
> Fixes:b0a242894f11d ("iio: adc: sun4i-gpadc-iio: register in the thermal after registering in pm")
> Signed-off-by: Zhang Qilong <zhangqilong3@xxxxxxxxxx>

Hi

There seems to be more wrong in the error handling in this function than your patch is fixing.

If you hit this error path, then the iio_map_array path has potentially been called, so
this should be a goto err_map I think.  Also, if this succeeds, but the
devm_iio_device_register() does not we don't unwind the thermal_zone registration.

Jonathan

> ---
>  drivers/iio/adc/sun4i-gpadc-iio.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/iio/adc/sun4i-gpadc-iio.c b/drivers/iio/adc/sun4i-gpadc-iio.c
> index a6ade70dedf8..ec0b09878d54 100644
> --- a/drivers/iio/adc/sun4i-gpadc-iio.c
> +++ b/drivers/iio/adc/sun4i-gpadc-iio.c
> @@ -648,7 +648,8 @@ static int sun4i_gpadc_probe(struct platform_device *pdev)
>  			dev_err(&pdev->dev,
>  				"could not register thermal sensor: %ld\n",
>  				PTR_ERR(info->tzd));
> -			return PTR_ERR(info->tzd);
> +			ret = PTR_ERR(info->tzd);
> +			goto err_pm;
>  		}
>  	}
>  
> @@ -663,7 +664,7 @@ static int sun4i_gpadc_probe(struct platform_device *pdev)
>  err_map:
>  	if (!info->no_irq && IS_ENABLED(CONFIG_THERMAL_OF))
>  		iio_map_array_unregister(indio_dev);
> -
> +err_pm:
>  	pm_runtime_put(&pdev->dev);
>  	pm_runtime_disable(&pdev->dev);
>  




[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