# Re: \[PATCH\] iio: adc128s052: Fix the error handling path of 'adc128\_probe()'

- From: Alexandru Ardelean \<hidden\>
- Date: 2021-08-23 06:42:39 
- List: kernel-janitors
- Page: https://ratatoskr.run/kernel-janitors/2021/08/1485394
- Thread: https://ratatoskr.run/linux-iio/2021/08/1484768/t.md

```text
On Sat, Aug 21, 2021 at 1:43 PM Christophe JAILLET
[ref] wrote:
>
> A successful 'regulator_enable()' call should be balanced by a
> corresponding 'regulator_disable()' call in the error handling path of the
> probe, as already done in the remove function.
>
> Update the error handling path accordingly.

Good catch.
For the fix:

Reviewed-by: Alexandru Ardelean <redacted>

If you want, you can also send a conversion to
devm_iio_device_register() for this driver.
And also move the regulator_disable() on a devm_add_action_or_reset() callback.
Maybe, that's already part of your plan. If so, apologies for the noise :)


>
> Fixes: 913b86468674 ("iio: adc: Add TI ADC128S052")
> Signed-off-by: Christophe JAILLET <redacted>
> ---
>  drivers/iio/adc/ti-adc128s052.c | 6 ++++++
>  1 file changed, 6 insertions(+)
>
> diff --git a/drivers/iio/adc/ti-adc128s052.c b/drivers/iio/adc/ti-adc128s052.c
> index 3143f35a6509..83c1ae07b3e9 100644
> --- a/drivers/iio/adc/ti-adc128s052.c
> +++ b/drivers/iio/adc/ti-adc128s052.c
> @@ -171,7 +171,13 @@ static int adc128_probe(struct spi_device *spi)
>         mutex_init(&adc->lock);
>
>         ret = iio_device_register(indio_dev);
> +       if (ret)
> +               goto err_disable_regulator;
>
> +       return 0;
> +
> +err_disable_regulator:
> +       regulator_disable(adc->reg);
>         return ret;
>  }
>
> --
> 2.30.2
>
```
