From: Arnd Bergmann <arnd@arndb.de>
To: Jonathan Cameron <jic23@kernel.org>
Cc: Arnd Bergmann <arnd@arndb.de>,
Lars-Peter Clausen <lars@metafoo.de>,
Michael Hennerich <Michael.Hennerich@analog.com>,
Hartmut Knaack <knaack.h@gmx.de>,
Peter Meerwald-Stadler <pmeerw@pmeerw.net>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Eva Rachel Retuya <eraretuya@gmail.com>,
linux-iio@vger.kernel.org, devel@driverdev.osuosl.org,
linux-kernel@vger.kernel.org
Subject: [PATCH] staging: iio: ad9832: allocate data before using
Date: Tue, 8 Nov 2016 15:00:49 +0100 [thread overview]
Message-ID: <20161108140115.2250646-1-arnd@arndb.de> (raw)
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
next reply other threads:[~2016-11-08 14:09 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-08 14:00 Arnd Bergmann [this message]
2016-11-08 20:24 ` [PATCH] staging: iio: ad9832: allocate data before using Jonathan Cameron
2016-11-09 6:51 ` Eva Rachel Retuya
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20161108140115.2250646-1-arnd@arndb.de \
--to=arnd@arndb.de \
--cc=Michael.Hennerich@analog.com \
--cc=devel@driverdev.osuosl.org \
--cc=eraretuya@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=jic23@kernel.org \
--cc=knaack.h@gmx.de \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pmeerw@pmeerw.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox