Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933460AbcKHUY0 (ORCPT ); Tue, 8 Nov 2016 15:24:26 -0500 Received: from saturn.retrosnub.co.uk ([178.18.118.26]:41861 "EHLO saturn.retrosnub.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752640AbcKHUYZ (ORCPT ); Tue, 8 Nov 2016 15:24:25 -0500 Subject: Re: [PATCH] staging: iio: ad9832: allocate data before using To: Arnd Bergmann References: <20161108140115.2250646-1-arnd@arndb.de> Cc: Lars-Peter Clausen , Michael Hennerich , Hartmut Knaack , Peter Meerwald-Stadler , Greg Kroah-Hartman , Eva Rachel Retuya , linux-iio@vger.kernel.org, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org From: Jonathan Cameron Message-ID: Date: Tue, 8 Nov 2016 20:24:18 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: <20161108140115.2250646-1-arnd@arndb.de> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2056 Lines: 61 On 08/11/16 14:00, Arnd Bergmann wrote: > 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 Thanks Arnd. I think I've gotten too reliant on zero day and clearly am not checking my local build warnings closely enough. Time to go back to doing pre push out checks more thoroughly. Anyhow, applied to the togreg branch of iio.git. Will probably be the weekend at least before I send another pull request. Thanks, Jonathan > --- > 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; > >