FAILED: patch "[PATCH] iio: adc: stm32-adc: fix possible division by zero in" failed to apply to 6.6-stable tree
Subsystems (3)
[email protected]
maintainerThe patch below does not apply to the 6.6-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.6.y
git checkout FETCH_HEAD
git cherry-pick -x c5de6a6f855fdcf1e0ea549fb227a316db51c405
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2026100606-vitally-sprain-dbc6@gregkh' --subject-prefix 'PATCH 6.6.y' 'HEAD^..'
Possible dependencies:
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From c5de6a6f855fdcf1e0ea549fb227a316db51c405 Mon Sep 17 00:00:00 2001
From: Fabrice Gasnier <[email protected]>
Date: Wed, 16 Sep 2026 19:15:04 +0200
Subject: [PATCH] iio: adc: stm32-adc: fix possible division by zero in
processed channel
In case the conversion has failed or returned zero, processing *val can lead to a division by zero. Need to check for errors, or converted value is zero, before processing the data. In case the converted value is zero, e.g. the Vrefint channel, this should be considered as invalid in all cases.
drivers/iio/adc/stm32-adc.c +9 -4
@@ -1608,11 +1608,16 @@ static int stm32_adc_read_raw(struct iio_dev *indio_dev, ret =stm32_adc_single_conv (indio_dev, chan, val); else ret = -EINVAL ; - -if (mask ==IIO_CHAN_INFO_PROCESSED ) - *val =STM32_ADC_VREFINT_VOLTAGE * adc->vrefint.vrefint_cal / *val; -iio_device_release_direct (indio_dev); +if (ret <0 ) +return ret; + +if (mask ==IIO_CHAN_INFO_PROCESSED ) { +if (*val ==0 ) +return -EINVAL ; + *val =STM32_ADC_VREFINT_VOLTAGE * adc->vrefint.vrefint_cal / *val; + } +return ret;case IIO_CHAN_INFO_SCALE :
Sasha Levin
maintainerPATCH 1/1 iio: adc: stm32-adc: fix possible division by zero in processed channel
From: Fabrice Gasnier <[email protected]>
[ Upstream commit c5de6a6f855fdcf1e0ea549fb227a316db51c405 ]
In case the conversion has failed or returned zero, processing *val can lead to a division by zero. Need to check for errors, or converted value is zero, before processing the data. In case the converted value is zero, e.g. the Vrefint channel, this should be considered as invalid in all cases.
--- drivers/iio/adc/stm32-adc.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/iio/adc/stm32-adc.c +7 -2
@@ -1478,11 +1478,16 @@ static int stm32_adc_read_raw(struct iio_dev *indio_dev, ret =stm32_adc_single_conv (indio_dev, chan, val); else ret = -EINVAL ; +iio_device_release_direct_mode (indio_dev); +if (ret <0 ) +return ret; -if (mask ==IIO_CHAN_INFO_PROCESSED ) +if (mask ==IIO_CHAN_INFO_PROCESSED ) { +if (*val ==0 ) +return -EINVAL ; *val =STM32_ADC_VREFINT_VOLTAGE * adc->vrefint.vrefint_cal / *val; + } -iio_device_release_direct_mode (indio_dev);return ret;case IIO_CHAN_INFO_SCALE :
Signature · 1 line
2.53.0