public inbox for linux-iio@vger.kernel.org
 help / color / mirror / Atom feed
From: "Nuno Sá" <noname.nuno@gmail.com>
To: Fabrizio Lamarque <fl.scratchpad@gmail.com>, linux-iio@vger.kernel.org
Cc: Jonathan Cameron <jic23@kernel.org>
Subject: Re: [PATCH v2 1/3] iio: adc: ad7192: Fix null pointer dereference on probe
Date: Thu, 13 Apr 2023 12:03:21 +0200	[thread overview]
Message-ID: <3916c0ae90b91342f153fa14160e8c5ef5d1c7f0.camel@gmail.com> (raw)
In-Reply-To: <CAPJMGm4bv3PHiGa7B8uH+izmVOWVJnibmuZ-9GwnAGeGHmpN5w@mail.gmail.com>

On Thu, 2023-04-13 at 10:28 +0200, Fabrizio Lamarque wrote:
> Pointer to indio_dev structure is obtained via spi_get_drvdata() at
> the beginning of function ad7192_setup(), but the spi->dev->driver_data
> member is not initialized, hence a NULL pointer is returned.
> 
> Fixed by changing ad7192_setup() signature to take pointer to struct
> iio_dev, and get ad7192_state pointer via st = iio_priv(indio_dev);
> 
> Fixes: bd5dcdeb3fd0 iio: adc: ad7192: convert to device-managed functions

This should be:
Fixes: bd5dcdeb3fd0 ("iio: adc: ad7192: convert to device-managed functions")

(applies to the other patches in the series).
> Signed-off-by: Fabrizio Lamarque <fl.scratchpad@gmail.com>
> ---

With the above fixed:

Reviewed-by: Nuno Sa <nuno.sa@analog.com>

> Changes in v2: obtained ad7192_state from iio_dev pointer as suggested
> by Jonathan, removed Reviewed-by since the entire patch changed its
> content.
> 
>  drivers/iio/adc/ad7192.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/iio/adc/ad7192.c b/drivers/iio/adc/ad7192.c
> index 55a6ab591016..94a9cf34a255 100644
> --- a/drivers/iio/adc/ad7192.c
> +++ b/drivers/iio/adc/ad7192.c
> @@ -380,9 +380,9 @@ static int ad7192_of_clock_select(struct ad7192_state *st)
>   return clock_sel;
>  }
> 
> -static int ad7192_setup(struct ad7192_state *st, struct device_node *np)
> +static int ad7192_setup(struct iio_dev *indio_dev, struct device_node *np)
>  {
> - struct iio_dev *indio_dev = spi_get_drvdata(st->sd.spi);
> + struct ad7192_state *st = iio_priv(indio_dev);
>   bool rej60_en, refin2_en;
>   bool buf_en, bipolar, burnout_curr_en;
>   unsigned long long scale_uv;
> @@ -1073,7 +1073,7 @@ static int ad7192_probe(struct spi_device *spi)
>   }
>   }
> 
> - ret = ad7192_setup(st, spi->dev.of_node);
> + ret = ad7192_setup(indio_dev, spi->dev.of_node);
>   if (ret)
>   return ret;
> 
> --
> 2.34.1


  parent reply	other threads:[~2023-04-13 10:01 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-13  8:26 [PATCH v2 0/3] iio: adc: ad7192: Functional fixes Fabrizio Lamarque
2023-04-13  8:28 ` [PATCH v2 1/3] iio: adc: ad7192: Fix null pointer dereference on probe Fabrizio Lamarque
2023-04-13  8:33   ` [PATCH 2/3] iio: adc: ad7192: Fix internal/external clock selection Fabrizio Lamarque
2023-04-13  8:36     ` [PATCH 3/3] iio: adc: ad7192: Clarify binding documentation Fabrizio Lamarque
2023-04-13 10:15       ` Nuno Sá
2023-04-13 10:47         ` Fabrizio Lamarque
2023-04-13 11:23           ` Nuno Sá
2023-04-13 14:21       ` Krzysztof Kozlowski
2023-04-13 16:07         ` Fabrizio Lamarque
2023-04-13 16:35           ` Krzysztof Kozlowski
2023-04-13 18:19             ` Fabrizio Lamarque
2023-04-14  9:18               ` Krzysztof Kozlowski
2023-04-14 10:42                 ` Fabrizio Lamarque
2023-04-15 16:38                   ` Jonathan Cameron
2023-04-26 10:45                     ` Fabrizio Lamarque
2023-05-01 16:03                       ` Jonathan Cameron
2023-04-13 10:04     ` [PATCH 2/3] iio: adc: ad7192: Fix internal/external clock selection Nuno Sá
2023-04-15 16:39     ` Jonathan Cameron
2023-04-13 10:03   ` Nuno Sá [this message]
2023-04-15 16:41   ` [PATCH v2 1/3] iio: adc: ad7192: Fix null pointer dereference on probe Jonathan Cameron

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=3916c0ae90b91342f153fa14160e8c5ef5d1c7f0.camel@gmail.com \
    --to=noname.nuno@gmail.com \
    --cc=fl.scratchpad@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