diff options
author | Martin Blumenstingl <martin.blumenstingl@googlemail.com> | 2017-06-04 09:28:23 -0400 |
---|---|---|
committer | Jonathan Cameron <jic23@kernel.org> | 2017-06-11 10:00:13 -0400 |
commit | 103a07d4278203d6299798cd74cdc4d209801cac (patch) | |
tree | 462b39551218c6aac93c12f7e521e28a076b596d | |
parent | 1454e15bc28ba94aa5d6b31a83a42d5c03af2a6d (diff) |
iio: adc: meson-saradc: fix potential crash in meson_sar_adc_clear_fifo
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>
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
-rw-r--r-- | drivers/iio/adc/meson_saradc.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/iio/adc/meson_saradc.c b/drivers/iio/adc/meson_saradc.c index dd4190b50df6..6066bbfc42fe 100644 --- a/drivers/iio/adc/meson_saradc.c +++ b/drivers/iio/adc/meson_saradc.c | |||
@@ -468,13 +468,13 @@ static void meson_sar_adc_unlock(struct iio_dev *indio_dev) | |||
468 | static void meson_sar_adc_clear_fifo(struct iio_dev *indio_dev) | 468 | static void meson_sar_adc_clear_fifo(struct iio_dev *indio_dev) |
469 | { | 469 | { |
470 | struct meson_sar_adc_priv *priv = iio_priv(indio_dev); | 470 | struct meson_sar_adc_priv *priv = iio_priv(indio_dev); |
471 | int count; | 471 | unsigned int count, tmp; |
472 | 472 | ||
473 | for (count = 0; count < MESON_SAR_ADC_MAX_FIFO_SIZE; count++) { | 473 | for (count = 0; count < MESON_SAR_ADC_MAX_FIFO_SIZE; count++) { |
474 | if (!meson_sar_adc_get_fifo_count(indio_dev)) | 474 | if (!meson_sar_adc_get_fifo_count(indio_dev)) |
475 | break; | 475 | break; |
476 | 476 | ||
477 | regmap_read(priv->regmap, MESON_SAR_ADC_FIFO_RD, 0); | 477 | regmap_read(priv->regmap, MESON_SAR_ADC_FIFO_RD, &tmp); |
478 | } | 478 | } |
479 | } | 479 | } |
480 | 480 | ||