From: Jonathan Cameron <jic23@kernel.org>
To: David Lechner <dlechner@baylibre.com>
Cc: linux-iio@vger.kernel.org,
"Michael Hennerich" <Michael.Hennerich@analog.com>,
"Angelo Dureghello" <adureghello@baylibre.com>,
"Alexandru Ardelean" <aardelean@baylibre.com>,
"Beniamin Bia" <beniamin.bia@analog.com>,
"Stefan Popa" <stefan.popa@analog.com>,
linux-kernel@vger.kernel.org, "Nuno Sá" <nuno.sa@analog.com>
Subject: Re: [PATCH v2 01/10] iio: adc: ad7606: check for NULL before calling sw_mode_config()
Date: Sun, 30 Mar 2025 18:56:08 +0100 [thread overview]
Message-ID: <20250330185608.20a4899a@jic23-huawei> (raw)
In-Reply-To: <20250318-iio-adc-ad7606-improvements-v2-1-4b605427774c@baylibre.com>
On Tue, 18 Mar 2025 17:52:09 -0500
David Lechner <dlechner@baylibre.com> wrote:
> Check that the sw_mode_config function pointer is not NULL before
> calling it. Not all buses define this callback, which resulted in a NULL
> pointer dereference.
>
> Fixes: e571c1902116 ("iio: adc: ad7606: move scale_setup as function pointer on chip-info")
> Reviewed-by: Nuno Sá <nuno.sa@analog.com>
> Signed-off-by: David Lechner <dlechner@baylibre.com>
Applied to my temporary fixes-togreg-testing branch. I'll rebase that once
Greg's pull request has been taken by Linus.
> ---
> drivers/iio/adc/ad7606.c | 11 ++++++++---
> 1 file changed, 8 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/iio/adc/ad7606.c b/drivers/iio/adc/ad7606.c
> index 1a314fddd7eb987b52016ce7242b446677f66427..703556eb7257ea0647135c4b268a8ead93115c6f 100644
> --- a/drivers/iio/adc/ad7606.c
> +++ b/drivers/iio/adc/ad7606.c
> @@ -1236,9 +1236,11 @@ static int ad7616_sw_mode_setup(struct iio_dev *indio_dev)
> st->write_scale = ad7616_write_scale_sw;
> st->write_os = &ad7616_write_os_sw;
>
> - ret = st->bops->sw_mode_config(indio_dev);
> - if (ret)
> - return ret;
> + if (st->bops->sw_mode_config) {
> + ret = st->bops->sw_mode_config(indio_dev);
> + if (ret)
> + return ret;
> + }
>
> /* Activate Burst mode and SEQEN MODE */
> return ad7606_write_mask(st, AD7616_CONFIGURATION_REGISTER,
> @@ -1268,6 +1270,9 @@ static int ad7606b_sw_mode_setup(struct iio_dev *indio_dev)
> st->write_scale = ad7606_write_scale_sw;
> st->write_os = &ad7606_write_os_sw;
>
> + if (!st->bops->sw_mode_config)
> + return 0;
> +
> return st->bops->sw_mode_config(indio_dev);
> }
>
>
next prev parent reply other threads:[~2025-03-30 17:56 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-18 22:52 [PATCH v2 00/10] iio: adc: ad7606: improvements and ad7606c parallel interface support David Lechner
2025-03-18 22:52 ` [PATCH v2 01/10] iio: adc: ad7606: check for NULL before calling sw_mode_config() David Lechner
2025-03-30 17:56 ` Jonathan Cameron [this message]
2025-03-18 22:52 ` [PATCH v2 02/10] iio: adc: ad7606_spi: check error in ad7606B_sw_mode_config() David Lechner
2025-03-30 17:58 ` Jonathan Cameron
2025-03-18 22:52 ` [PATCH v2 03/10] iio: adc: ad7606: add missing max sample rates David Lechner
2025-03-18 22:52 ` [PATCH v2 04/10] iio: adc: ad7606: use devm_mutex_init() David Lechner
2025-03-18 22:52 ` [PATCH v2 05/10] iio: adc: ad7606: fix kernel-doc comments David Lechner
2025-03-18 22:52 ` [PATCH v2 06/10] iio: adc: ad7606: use kernel identifier name style David Lechner
2025-03-18 22:52 ` [PATCH v2 07/10] iio: adc: ad7606: don't use address field David Lechner
2025-03-18 22:52 ` [PATCH v2 08/10] iio: adc: ad7606: drop ch param from ad7606_scale_setup_cb_t David Lechner
2025-03-30 18:01 ` Jonathan Cameron
2025-03-18 22:52 ` [PATCH v2 09/10] iio: adc: ad7606: dynamically allocate channel info David Lechner
2025-03-22 17:25 ` Dan Carpenter
2025-03-24 13:50 ` David Lechner
2025-03-30 18:07 ` Jonathan Cameron
2025-03-18 22:52 ` [PATCH v2 10/10] iio: adc: ad7606_par: add ad7606c chips David Lechner
2025-03-30 18:08 ` 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=20250330185608.20a4899a@jic23-huawei \
--to=jic23@kernel.org \
--cc=Michael.Hennerich@analog.com \
--cc=aardelean@baylibre.com \
--cc=adureghello@baylibre.com \
--cc=beniamin.bia@analog.com \
--cc=dlechner@baylibre.com \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nuno.sa@analog.com \
--cc=stefan.popa@analog.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