* [bug report] staging: iio: ad9832: clean-up regulator 'reg'
@ 2016-11-15 11:02 Dan Carpenter
2016-11-15 13:11 ` Eva Rachel Retuya
0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2016-11-15 11:02 UTC (permalink / raw)
To: eraretuya, Jonathan Cameron; +Cc: linux-iio
[ This patch generates a GCC warning as well... I have no idea how we
failed so badly. -dan ]
Hello Eva Rachel Retuya,
The patch 43a07e48af44: "staging: iio: ad9832: clean-up regulator
'reg'" from Nov 1, 2016, leads to the following static checker
warning:
drivers/staging/iio/frequency/ad9832.c:214 ad9832_probe()
error: potentially dereferencing uninitialized 'st'.
drivers/staging/iio/frequency/ad9832.c
202 static int ad9832_probe(struct spi_device *spi)
203 {
204 struct ad9832_platform_data *pdata = dev_get_platdata(&spi->dev);
205 struct iio_dev *indio_dev;
206 struct ad9832_state *st;
207 int ret;
208
209 if (!pdata) {
210 dev_dbg(&spi->dev, "no platform data?\n");
211 return -ENODEV;
212 }
213
214 st->avdd = devm_regulator_get(&spi->dev, "avdd");
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Oops.
215 if (IS_ERR(st->avdd))
216 return PTR_ERR(st->avdd);
217
218 ret = regulator_enable(st->avdd);
219 if (ret) {
220 dev_err(&spi->dev, "Failed to enable specified AVDD supply\n");
221 return ret;
222 }
223
224 st->dvdd = devm_regulator_get(&spi->dev, "dvdd");
225 if (IS_ERR(st->dvdd)) {
226 ret = PTR_ERR(st->dvdd);
227 goto error_disable_avdd;
228 }
229
230 ret = regulator_enable(st->dvdd);
231 if (ret) {
232 dev_err(&spi->dev, "Failed to enable specified DVDD supply\n");
233 goto error_disable_avdd;
234 }
235
236 indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st));
237 if (!indio_dev) {
238 ret = -ENOMEM;
239 goto error_disable_dvdd;
240 }
241 spi_set_drvdata(spi, indio_dev);
242 st = iio_priv(indio_dev);
^^^^^^^^^^^^^^^^^^^^^^^^
"st" isn't initialized until here.
243 st->mclk = pdata->mclk;
244 st->spi = spi;
regards,
dan carpenter
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [bug report] staging: iio: ad9832: clean-up regulator 'reg'
2016-11-15 11:02 [bug report] staging: iio: ad9832: clean-up regulator 'reg' Dan Carpenter
@ 2016-11-15 13:11 ` Eva Rachel Retuya
0 siblings, 0 replies; 2+ messages in thread
From: Eva Rachel Retuya @ 2016-11-15 13:11 UTC (permalink / raw)
To: Dan Carpenter; +Cc: Jonathan Cameron, linux-iio
On Tue, Nov 15, 2016 at 02:02:12PM +0300, Dan Carpenter wrote:
> [ This patch generates a GCC warning as well... I have no idea how we
> failed so badly. -dan ]
>
> Hello Eva Rachel Retuya,
>
> The patch 43a07e48af44: "staging: iio: ad9832: clean-up regulator
> 'reg'" from Nov 1, 2016, leads to the following static checker
> warning:
>
> drivers/staging/iio/frequency/ad9832.c:214 ad9832_probe()
> error: potentially dereferencing uninitialized 'st'.
>
Thank you for bringing this up. A patch has already been sent to fix it:
https://git.kernel.org/cgit/linux/kernel/git/jic23/iio.git/commit/?h=testing&id=6826fdbd2e207f8107e65c5a372ac616e7af11b4
Eva
> drivers/staging/iio/frequency/ad9832.c
> 202 static int ad9832_probe(struct spi_device *spi)
> 203 {
> 204 struct ad9832_platform_data *pdata = dev_get_platdata(&spi->dev);
> 205 struct iio_dev *indio_dev;
> 206 struct ad9832_state *st;
> 207 int ret;
> 208
> 209 if (!pdata) {
> 210 dev_dbg(&spi->dev, "no platform data?\n");
> 211 return -ENODEV;
> 212 }
> 213
> 214 st->avdd = devm_regulator_get(&spi->dev, "avdd");
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> Oops.
>
> 215 if (IS_ERR(st->avdd))
> 216 return PTR_ERR(st->avdd);
> 217
> 218 ret = regulator_enable(st->avdd);
> 219 if (ret) {
> 220 dev_err(&spi->dev, "Failed to enable specified AVDD supply\n");
> 221 return ret;
> 222 }
> 223
> 224 st->dvdd = devm_regulator_get(&spi->dev, "dvdd");
> 225 if (IS_ERR(st->dvdd)) {
> 226 ret = PTR_ERR(st->dvdd);
> 227 goto error_disable_avdd;
> 228 }
> 229
> 230 ret = regulator_enable(st->dvdd);
> 231 if (ret) {
> 232 dev_err(&spi->dev, "Failed to enable specified DVDD supply\n");
> 233 goto error_disable_avdd;
> 234 }
> 235
> 236 indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st));
> 237 if (!indio_dev) {
> 238 ret = -ENOMEM;
> 239 goto error_disable_dvdd;
> 240 }
> 241 spi_set_drvdata(spi, indio_dev);
> 242 st = iio_priv(indio_dev);
> ^^^^^^^^^^^^^^^^^^^^^^^^
> "st" isn't initialized until here.
>
>
> 243 st->mclk = pdata->mclk;
> 244 st->spi = spi;
>
>
> regards,
> dan carpenter
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-11-15 13:11 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-11-15 11:02 [bug report] staging: iio: ad9832: clean-up regulator 'reg' Dan Carpenter
2016-11-15 13:11 ` Eva Rachel Retuya
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).