linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Crt Mori <cmo@melexis.com>, linux-iio@vger.kernel.org
Cc: Lars-Peter Clausen <lars@metafoo.de>,
	Dan Carpenter <dan.carpenter@oracle.com>,
	Hartmut Knaack <knaack.h@gmx.de>,
	Peter Meerwald-Stadler <pmeerw@pmeerw.net>,
	Linus Walleij <linus.walleij@linaro.org>
Subject: Re: [PATCH] [BUGFIX] iio: ms65611_core: Fixes dereferencing regulator pointer
Date: Sat, 15 Oct 2016 14:56:14 +0100	[thread overview]
Message-ID: <86b79b54-2aab-57cc-1fa5-e40b36368743@kernel.org> (raw)
In-Reply-To: <20161014134314.2608-1-cmo@melexis.com>

On 14/10/16 14:43, Crt Mori wrote:
> Change in handling of the regulator description means that static
> checkers correctly assume we could be using dereferenced pointer to the
> regulator. In reality we will never get the -ENODEV error, as current
> behavior flow does not predict it, because:
> If the device tree or board file does not define suitable regulators for
> the component, it will be substituted by a dummy regulator, or, if
> regulators are disabled altogether, by stubs.
> 
> Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
> Suggested-by: Lars-Peter Clausen <lars@metafoo.de>
> Signed-off-by: Crt Mori <cmo@melexis.com>
Applied to the togreg branch of iio.git and pushed out as testing for the
autobuilders to play with it.

Thanks,

Jonathan
> ---
>  drivers/iio/pressure/ms5611_core.c | 19 ++++++++-----------
>  1 file changed, 8 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/iio/pressure/ms5611_core.c b/drivers/iio/pressure/ms5611_core.c
> index a74ed1f..6bd53e7 100644
> --- a/drivers/iio/pressure/ms5611_core.c
> +++ b/drivers/iio/pressure/ms5611_core.c
> @@ -392,17 +392,14 @@ static int ms5611_init(struct iio_dev *indio_dev)
>  
>  	/* Enable attached regulator if any. */
>  	st->vdd = devm_regulator_get(indio_dev->dev.parent, "vdd");
> -	if (!IS_ERR(st->vdd)) {
> -		ret = regulator_enable(st->vdd);
> -		if (ret) {
> -			dev_err(indio_dev->dev.parent,
> -				"failed to enable Vdd supply: %d\n", ret);
> -			return ret;
> -		}
> -	} else {
> -		ret = PTR_ERR(st->vdd);
> -		if (ret != -ENODEV)
> -			return ret;
> +	if (IS_ERR(st->vdd))
> +		return PTR_ERR(st->vdd);
> +
> +	ret = regulator_enable(st->vdd);
> +	if (ret) {
> +		dev_err(indio_dev->dev.parent,
> +			"failed to enable Vdd supply: %d\n", ret);
> +		return ret;
>  	}
>  
>  	ret = ms5611_reset(indio_dev);
> 


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

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-14 13:43 [PATCH] [BUGFIX] iio: ms65611_core: Fixes dereferencing regulator pointer Crt Mori
2016-10-15 13:56 ` Jonathan Cameron [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=86b79b54-2aab-57cc-1fa5-e40b36368743@kernel.org \
    --to=jic23@kernel.org \
    --cc=cmo@melexis.com \
    --cc=dan.carpenter@oracle.com \
    --cc=knaack.h@gmx.de \
    --cc=lars@metafoo.de \
    --cc=linus.walleij@linaro.org \
    --cc=linux-iio@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;
as well as URLs for NNTP newsgroup(s).