linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Eva Rachel Retuya <eraretuya@gmail.com>
To: Dan Carpenter <dan.carpenter@oracle.com>
Cc: Jonathan Cameron <jic23@kernel.org>, linux-iio@vger.kernel.org
Subject: Re: [bug report] staging: iio: ad9832: clean-up regulator 'reg'
Date: Tue, 15 Nov 2016 21:11:19 +0800	[thread overview]
Message-ID: <20161115131118.GA2293@Socrates-DK> (raw)
In-Reply-To: <20161115110212.GA776@mwanda>

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

      reply	other threads:[~2016-11-15 13:11 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 message]

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=20161115131118.GA2293@Socrates-DK \
    --to=eraretuya@gmail.com \
    --cc=dan.carpenter@oracle.com \
    --cc=jic23@kernel.org \
    --cc=linux-iio@vger.kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).