2020-05-17 10:04:07

by Christophe JAILLET

[permalink] [raw]
Subject: [PATCH] iio: adc: ad7780: Fix a resource handling path in 'ad7780_probe()'

If 'ad7780_init_gpios()' fails, we must not release some resources that
have not been allocated yet. Return directly instead.

Fixes: 5bb30e7daf00 ("staging: iio: ad7780: move regulator to after GPIO init")
Fixes: 9085daa4abcc ("staging: iio: ad7780: add gain & filter gpio support")
Signed-off-by: Christophe JAILLET <[email protected]>
---
drivers/iio/adc/ad7780.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/iio/adc/ad7780.c b/drivers/iio/adc/ad7780.c
index f47606ebbbbe..b33fe6c3907e 100644
--- a/drivers/iio/adc/ad7780.c
+++ b/drivers/iio/adc/ad7780.c
@@ -329,7 +329,7 @@ static int ad7780_probe(struct spi_device *spi)

ret = ad7780_init_gpios(&spi->dev, st);
if (ret)
- goto error_cleanup_buffer_and_trigger;
+ return ret;

st->reg = devm_regulator_get(&spi->dev, "avdd");
if (IS_ERR(st->reg))
--
2.25.1


2020-05-18 02:26:42

by Renato Lui Geh

[permalink] [raw]
Subject: Re: [PATCH] iio: adc: ad7780: Fix a resource handling path in 'ad7780_probe()'

Acked-by: Renato Lui Geh <[email protected]>

On 05/17, Christophe JAILLET wrote:
>If 'ad7780_init_gpios()' fails, we must not release some resources that
>have not been allocated yet. Return directly instead.
>
>Fixes: 5bb30e7daf00 ("staging: iio: ad7780: move regulator to after GPIO init")
>Fixes: 9085daa4abcc ("staging: iio: ad7780: add gain & filter gpio support")
>Signed-off-by: Christophe JAILLET <[email protected]>
>---
> drivers/iio/adc/ad7780.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
>diff --git a/drivers/iio/adc/ad7780.c b/drivers/iio/adc/ad7780.c
>index f47606ebbbbe..b33fe6c3907e 100644
>--- a/drivers/iio/adc/ad7780.c
>+++ b/drivers/iio/adc/ad7780.c
>@@ -329,7 +329,7 @@ static int ad7780_probe(struct spi_device *spi)
>
> ret = ad7780_init_gpios(&spi->dev, st);
> if (ret)
>- goto error_cleanup_buffer_and_trigger;
>+ return ret;
>
> st->reg = devm_regulator_get(&spi->dev, "avdd");
> if (IS_ERR(st->reg))
>--
>2.25.1
>

2020-07-05 12:00:23

by Jonathan Cameron

[permalink] [raw]
Subject: Re: [PATCH] iio: adc: ad7780: Fix a resource handling path in 'ad7780_probe()'

On Sun, 17 May 2020 23:21:29 -0300
Renato Lui Geh <[email protected]> wrote:

> Acked-by: Renato Lui Geh <[email protected]>
>
> On 05/17, Christophe JAILLET wrote:
> >If 'ad7780_init_gpios()' fails, we must not release some resources that
> >have not been allocated yet. Return directly instead.
> >
> >Fixes: 5bb30e7daf00 ("staging: iio: ad7780: move regulator to after GPIO init")
> >Fixes: 9085daa4abcc ("staging: iio: ad7780: add gain & filter gpio support")
> >Signed-off-by: Christophe JAILLET <[email protected]>
Applied to the fixes-togreg branch of iio.git.

Thanks,

Jonathan

> >---
> > drivers/iio/adc/ad7780.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> >diff --git a/drivers/iio/adc/ad7780.c b/drivers/iio/adc/ad7780.c
> >index f47606ebbbbe..b33fe6c3907e 100644
> >--- a/drivers/iio/adc/ad7780.c
> >+++ b/drivers/iio/adc/ad7780.c
> >@@ -329,7 +329,7 @@ static int ad7780_probe(struct spi_device *spi)
> >
> > ret = ad7780_init_gpios(&spi->dev, st);
> > if (ret)
> >- goto error_cleanup_buffer_and_trigger;
> >+ return ret;
> >
> > st->reg = devm_regulator_get(&spi->dev, "avdd");
> > if (IS_ERR(st->reg))
> >--
> >2.25.1
> >