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

On Thu, 13 Apr 2023 10:28:11 +0200
Fabrizio Lamarque <fl.scratchpad@gmail.com> 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
> Signed-off-by: Fabrizio Lamarque <fl.scratchpad@gmail.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.

Great. Please just tidy up the Fixes tag formatting and send a v3.

Note that we are very late in current cycle, so I'll only queue these
up now for after 6.4-rc1 is available.  They'll get pulled back into stable
trees after that (in about 3-4 weeks time).

Thanks,

Jonathan

> 
>  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-15 16:41 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   ` [PATCH v2 1/3] iio: adc: ad7192: Fix null pointer dereference on probe Nuno Sá
2023-04-15 16:41   ` 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=20230415174104.7f1370c0@jic23-huawei \
    --to=jic23@kernel.org \
    --cc=fl.scratchpad@gmail.com \
    --cc=linux-iio@vger.kernel.org \
    --cc=noname.nuno@gmail.com \
    /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