linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: eraretuya@gmail.com, Jonathan Cameron <jic23@kernel.org>
Cc: linux-iio@vger.kernel.org
Subject: [bug report] staging: iio: ad9832: clean-up regulator 'reg'
Date: Tue, 15 Nov 2016 14:02:12 +0300	[thread overview]
Message-ID: <20161115110212.GA776@mwanda> (raw)

[ 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

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

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-15 11:02 Dan Carpenter [this message]
2016-11-15 13:11 ` [bug report] staging: iio: ad9832: clean-up regulator 'reg' 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=20161115110212.GA776@mwanda \
    --to=dan.carpenter@oracle.com \
    --cc=eraretuya@gmail.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).