From: sashiko-bot@kernel.org
To: "Fabrice Gasnier" <fabrice.gasnier@foss.st.com>
Cc: robh@kernel.org, conor+dt@kernel.org, devicetree@vger.kernel.org
Subject: Re: [PATCH 2/8] iio: adc: stm32-adc: manage characterization voltage diversity
Date: Fri, 11 Sep 2026 16:15:54 +0000 [thread overview]
Message-ID: <20260911161555.244F31F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260911-adc-stm32mp25-v1-v1-2-cef26eecdef2@foss.st.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [Critical] Missing error check after ADC conversion allows division by zero or division by uninitialized memory if the conversion fails or returns zero.
--
commit 0d19a7183285228478d5cfa82a3785b87f3e1bd1
Author: Olivier Moysan <olivier.moysan@foss.st.com>
iio: adc: stm32-adc: manage characterization voltage diversity
This commit introduces a vref_charac field in stm32_adc_cfg to store
SoC-specific characterization voltage. It updates the stm32_adc_read_raw
function to use this field in the vref computation formula.
> diff --git a/drivers/iio/adc/stm32-adc.c b/drivers/iio/adc/stm32-adc.c
> --- a/drivers/iio/adc/stm32-adc.c
> +++ b/drivers/iio/adc/stm32-adc.c
[ ... ]
> @@ -1610,7 +1611,7 @@ static int stm32_adc_read_raw(struct iio_dev *indio_dev,
> ret = -EINVAL;
>
> if (mask == IIO_CHAN_INFO_PROCESSED)
> - *val = STM32_ADC_VREFINT_VOLTAGE * adc->vrefint.vrefint_cal / *val;
> + *val = adc->cfg->vref_charac * adc->vrefint.vrefint_cal / *val;
[Severity: Critical]
This isn't a bug introduced by this patch, but does this division need to
check if the conversion actually succeeded?
Looking at the preceding code in stm32_adc_read_raw():
if (chan->type == IIO_VOLTAGE)
ret = stm32_adc_single_conv(indio_dev, chan, val);
else
ret = -EINVAL;
If a sysfs read (such as in_voltageX_input) is interrupted by a signal,
stm32_adc_single_conv() can abort via wait_for_completion_interruptible_timeout()
and return an error like -ERESTARTSYS. When this happens, *val remains
uninitialized.
Since there is no error check on ret before the division, this code will
proceed to divide by the uninitialized *val. If the kernel is compiled with
CONFIG_INIT_STACK_ALL_ZERO=y, the uninitialized stack variable will be 0,
which could lead to a division by zero kernel panic.
Should we verify that ret indicates success and that *val is non-zero
before attempting the scaling calculation?
>
> iio_device_release_direct(indio_dev);
> return ret;
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260911-adc-stm32mp25-v1-v1-0-cef26eecdef2@foss.st.com?part=2
next prev parent reply other threads:[~2026-09-11 16:15 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-11 15:51 [PATCH 0/8] iio: adc: stm32: add support for stm32mp23 and stm32mp25 Fabrice Gasnier
2026-09-11 15:51 ` [PATCH 1/8] dt-bindings: iio: adc: stm32-adc: " Fabrice Gasnier
2026-09-11 16:02 ` sashiko-bot
2026-09-11 18:08 ` Marek Vasut
2026-09-13 3:08 ` Jonathan Cameron
2026-09-11 15:51 ` [PATCH 2/8] iio: adc: stm32-adc: manage characterization voltage diversity Fabrice Gasnier
2026-09-11 16:10 ` Andy Shevchenko
2026-09-11 16:15 ` sashiko-bot [this message]
2026-09-11 15:51 ` [PATCH 3/8] iio: adc: stm32-adc: add support for stm32mp23 and stm32mp25 Fabrice Gasnier
2026-09-11 16:22 ` Andy Shevchenko
2026-09-11 16:26 ` sashiko-bot
2026-09-13 3:25 ` Jonathan Cameron
2026-09-11 15:51 ` [PATCH 4/8] arm64: dts: st: add vrefint calibration on stm32mp23 Fabrice Gasnier
2026-09-11 18:10 ` Marek Vasut
2026-09-11 15:51 ` [PATCH 5/8] arm64: dts: st: add vrefint calibration on stm32mp25 Fabrice Gasnier
2026-09-11 15:51 ` [PATCH 6/8] arm64: dts: st: add ADC nodes on stm32mp231 Fabrice Gasnier
2026-09-11 15:51 ` [PATCH 7/8] arm64: dts: st: add ADC nodes on stm32mp251 Fabrice Gasnier
2026-09-11 15:51 ` [PATCH 8/8] arm64: dts: st: add ADC support on stm32mp257f-ev1 board Fabrice Gasnier
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=20260911161555.244F31F000FF@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=fabrice.gasnier@foss.st.com \
--cc=robh@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.