mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-08-23 17:30:02 +00:00
staging: iio: ad9832: allocate data before using
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:43a07e48af
("staging: iio: ad9832: clean-up regulator 'reg'") Fixes:a98461d79b
("staging: iio: ad9832: add DVDD regulator") Signed-off-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Jonathan Cameron <jic23@kernel.org>
This commit is contained in:
parent
993403b979
commit
6826fdbd2e
1 changed files with 7 additions and 7 deletions
|
@ -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;
|
||||
|
||||
|
|
Loading…
Reference in a new issue