Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1517235
| From | Arnd Bergmann <arnd@arndb.de> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH] staging: iio: ad9832: allocate data before using |
| Date | 2016-11-08 15:20 +0100 |
| Message-ID | <sBfpM-20X-21@gated-at.bofh.it> (permalink) |
| Organization | linux.* mail to news gateway |
The regulator changes assigned data to an uninitialized pointer:
drivers/staging/iio/frequency/ad9832.c: In function 'ad9832_probe':
drivers/staging/iio/frequency/ad9832.c:214:11: error: 'st' may be used uninitialized in this function [-Werror=maybe-uninitialized]
This moves the allocation of the 'st' structure before its first
use, as it should have been.
Fixes: 43a07e48af44 ("staging: iio: ad9832: clean-up regulator 'reg'")
Fixes: a98461d79ba5 ("staging: iio: ad9832: add DVDD regulator")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
drivers/staging/iio/frequency/ad9832.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/drivers/staging/iio/frequency/ad9832.c b/drivers/staging/iio/frequency/ad9832.c
index 639047fade30..a5b2f068168d 100644
--- a/drivers/staging/iio/frequency/ad9832.c
+++ b/drivers/staging/iio/frequency/ad9832.c
@@ -211,6 +211,13 @@ static int ad9832_probe(struct spi_device *spi)
return -ENODEV;
}
+ indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st));
+ if (!indio_dev)
+ return -ENOMEM;
+
+ spi_set_drvdata(spi, indio_dev);
+ st = iio_priv(indio_dev);
+
st->avdd = devm_regulator_get(&spi->dev, "avdd");
if (IS_ERR(st->avdd))
return PTR_ERR(st->avdd);
@@ -233,13 +240,6 @@ static int ad9832_probe(struct spi_device *spi)
goto error_disable_avdd;
}
- indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st));
- if (!indio_dev) {
- ret = -ENOMEM;
- goto error_disable_dvdd;
- }
- spi_set_drvdata(spi, indio_dev);
- st = iio_priv(indio_dev);
st->mclk = pdata->mclk;
st->spi = spi;
--
2.9.0
Back to linux.kernel | Previous | Next — Next in thread | Find similar | Unroll thread
[PATCH] staging: iio: ad9832: allocate data before using Arnd Bergmann <arnd@arndb.de> - 2016-11-08 15:20 +0100 Re: [PATCH] staging: iio: ad9832: allocate data before using Jonathan Cameron <jic23@kernel.org> - 2016-11-08 21:30 +0100 Re: [PATCH] staging: iio: ad9832: allocate data before using Eva Rachel Retuya <eraretuya@gmail.com> - 2016-11-09 08:00 +0100
csiph-web