linux-iio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
Cc: linux-iio@vger.kernel.org, paolocretaro@gmail.com,
	knaack.h@gmx.de, lars@metafoo.de, pmeerw@pmeerw.net,
	linux-amlogic@lists.infradead.org
Subject: Re: [PATCH] iio: adc: meson-saradc: fix potential crash in meson_sar_adc_clear_fifo
Date: Sun, 11 Jun 2017 15:01:46 +0100	[thread overview]
Message-ID: <20170611150146.67423c44@kernel.org> (raw)
In-Reply-To: <20170604132823.21928-1-martin.blumenstingl@googlemail.com>

On Sun,  4 Jun 2017 15:28:23 +0200
Martin Blumenstingl <martin.blumenstingl@googlemail.com> wrote:

> meson_sar_adc_clear_fifo passes a 0 as value-pointer to regmap_read().
> In case of the meson-saradc driver this ends up in regmap_mmio_read(),
> where the value-pointer is de-referenced unconditionally to assign the
> value which was read.
> Fix this by passing an actual pointer, even though all we want to do is
> to discard the value.
> 
> As a side-effect this fixes a sparse warning ("Using plain integer as
> NULL pointer") as reported by Paolo Cretaro.
> 
> Fixes: 3adbf3427330 ("iio: adc: add a driver for the SAR ADC found in Amlogic Meson SoCs")
> Reported-by: Paolo Cretaro <paolocretaro@gmail.com>
> Signed-off-by: Martin Blumenstingl <martin.blumenstingl@googlemail.com>
Applied to the fixes-togreg branch of iio.git.

Thanks,

Jonathan
> ---
>  drivers/iio/adc/meson_saradc.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/iio/adc/meson_saradc.c b/drivers/iio/adc/meson_saradc.c
> index 81cd39a57fe3..83da50ed73ab 100644
> --- a/drivers/iio/adc/meson_saradc.c
> +++ b/drivers/iio/adc/meson_saradc.c
> @@ -475,13 +475,13 @@ static void meson_sar_adc_unlock(struct iio_dev *indio_dev)
>  static void meson_sar_adc_clear_fifo(struct iio_dev *indio_dev)
>  {
>  	struct meson_sar_adc_priv *priv = iio_priv(indio_dev);
> -	int count;
> +	unsigned int count, tmp;
>  
>  	for (count = 0; count < MESON_SAR_ADC_MAX_FIFO_SIZE; count++) {
>  		if (!meson_sar_adc_get_fifo_count(indio_dev))
>  			break;
>  
> -		regmap_read(priv->regmap, MESON_SAR_ADC_FIFO_RD, 0);
> +		regmap_read(priv->regmap, MESON_SAR_ADC_FIFO_RD, &tmp);
>  	}
>  }
>  


      reply	other threads:[~2017-06-11 14:01 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-04 13:28 [PATCH] iio: adc: meson-saradc: fix potential crash in meson_sar_adc_clear_fifo Martin Blumenstingl
2017-06-11 14:01 ` 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=20170611150146.67423c44@kernel.org \
    --to=jic23@kernel.org \
    --cc=knaack.h@gmx.de \
    --cc=lars@metafoo.de \
    --cc=linux-amlogic@lists.infradead.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=martin.blumenstingl@googlemail.com \
    --cc=paolocretaro@gmail.com \
    --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).