iio: gyro: adis16260: fix division by zero in write_raw
Subsystems (2)
PATCH 1/1 iio: gyro: adis16260: fix division by zero in write_raw
Add a validation check for the sampling frequency value before using it as a divisor. A user writing zero to the sampling_frequency sysfs attribute triggers a division by zero in the kernel.
Fixes 089a41985c6c ("staging: iio: adis16260 digital gyro driver")
Signed-off-by Antoniu Miclaus <[email protected]>
--- drivers/iio/gyro/adis16260.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/iio/gyro/adis16260.c +3 -0
@@ -287,6 +287,9 @@ static int adis16260_write_raw(struct iio_dev *indio_dev, addr = adis16260_addresses[chan->scan_index][1 ];return adis_write_reg_16 (adis, addr, val);case IIO_CHAN_INFO_SAMP_FREQ : +if (val <=0 ) +return -EINVAL ; +if (spi_get_device_id (adis->spi)->driver_data) t =256 / val;else
Signature · 1 line
2.43.0
Quoted 7 lines · Antoniu Miclaus
Add a validation check for the sampling frequency value before using it as a divisor. A user writing zero to the
sampling_frequencysysfs attribute triggers a division by zero in the kernel.Fixes 089a41985c6c ("staging: iio: adis16260 digital gyro driver")Signed-off-by Antoniu Miclaus <[email protected]>---
Reviewed-by Nuno Sá <[email protected]>
Quoted 20 lines
drivers/iio/gyro/adis16260.c | 3 +++ 1 file changed, 3 insertions(+)drivers/iio/gyro/adis16260.c +3
-0@@ -287,6 +287,9 @@ static int adis16260_write_raw(struct iio_dev *indio_dev, addr = adis16260_addresses[chan->scan_index][1 ];return adis_write_reg_16 (adis, addr, val);case IIO_CHAN_INFO_SAMP_FREQ : +if (val <=0 ) +return -EINVAL ; +if (spi_get_device_id (adis->spi)->driver_data) t =256 / val;else Signature · 1 line
2.43.0
Quoted 10 lines · On Tue, 31 Mar 2026 12:04:45 +0100 Nuno Sá <[email protected]> wrote:
Quoted 7 lines · Antoniu Miclaus
Add a validation check for the sampling frequency value before using it as a divisor. A user writing zero to the
sampling_frequencysysfs attribute triggers a division by zero in the kernel.Fixes 089a41985c6c ("staging: iio: adis16260 digital gyro driver")Signed-off-by Antoniu Miclaus <[email protected]>---
Reviewed-by Nuno Sá <[email protected]>
Applied to the fixes-togreg branch of iio.git and marked for stable.
Thanks,
Jonathan
Quoted 21 lines
Quoted 21 lines
drivers/iio/gyro/adis16260.c | 3 +++ 1 file changed, 3 insertions(+)drivers/iio/gyro/adis16260.c +3
-0@@ -287,6 +287,9 @@ static int adis16260_write_raw(struct iio_dev *indio_dev, addr = adis16260_addresses[chan->scan_index][1 ];return adis_write_reg_16 (adis, addr, val);case IIO_CHAN_INFO_SAMP_FREQ : +if (val <=0 ) +return -EINVAL ; +if (spi_get_device_id (adis->spi)->driver_data) t =256 / val;else Signature · 1 line
2.43.0