* [PATCH] iio: gyro: adis16260: fix division by zero in write_raw
@ 2026-03-31 10:13 Antoniu Miclaus
2026-03-31 11:04 ` Nuno Sá
0 siblings, 1 reply; 3+ messages in thread
From: Antoniu Miclaus @ 2026-03-31 10:13 UTC (permalink / raw)
To: Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron,
David Lechner, Nuno Sá, Greg Kroah-Hartman, Barry Song,
linux-iio, linux-kernel
Cc: Antoniu Miclaus
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 <antoniu.miclaus@analog.com>
---
drivers/iio/gyro/adis16260.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/iio/gyro/adis16260.c b/drivers/iio/gyro/adis16260.c
index 586e6cfa14a9..91b9c5f18ec4 100644
--- a/drivers/iio/gyro/adis16260.c
+++ b/drivers/iio/gyro/adis16260.c
@@ -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
--
2.43.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] iio: gyro: adis16260: fix division by zero in write_raw
2026-03-31 10:13 [PATCH] iio: gyro: adis16260: fix division by zero in write_raw Antoniu Miclaus
@ 2026-03-31 11:04 ` Nuno Sá
2026-04-13 19:45 ` Jonathan Cameron
0 siblings, 1 reply; 3+ messages in thread
From: Nuno Sá @ 2026-03-31 11:04 UTC (permalink / raw)
To: Antoniu Miclaus
Cc: Lars-Peter Clausen, Michael Hennerich, Jonathan Cameron,
David Lechner, Nuno Sá, Greg Kroah-Hartman, Barry Song,
linux-iio, linux-kernel
On Tue, Mar 31, 2026 at 01:13:00PM +0300, Antoniu Miclaus wrote:
> 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 <antoniu.miclaus@analog.com>
> ---
Reviewed-by: Nuno Sá <nuno.sa@analog.com>
> drivers/iio/gyro/adis16260.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/drivers/iio/gyro/adis16260.c b/drivers/iio/gyro/adis16260.c
> index 586e6cfa14a9..91b9c5f18ec4 100644
> --- a/drivers/iio/gyro/adis16260.c
> +++ b/drivers/iio/gyro/adis16260.c
> @@ -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
> --
> 2.43.0
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] iio: gyro: adis16260: fix division by zero in write_raw
2026-03-31 11:04 ` Nuno Sá
@ 2026-04-13 19:45 ` Jonathan Cameron
0 siblings, 0 replies; 3+ messages in thread
From: Jonathan Cameron @ 2026-04-13 19:45 UTC (permalink / raw)
To: Nuno Sá
Cc: Antoniu Miclaus, Lars-Peter Clausen, Michael Hennerich,
David Lechner, Nuno Sá, Greg Kroah-Hartman, Barry Song,
linux-iio, linux-kernel
On Tue, 31 Mar 2026 12:04:45 +0100
Nuno Sá <noname.nuno@gmail.com> wrote:
> On Tue, Mar 31, 2026 at 01:13:00PM +0300, Antoniu Miclaus wrote:
> > 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 <antoniu.miclaus@analog.com>
> > ---
>
> Reviewed-by: Nuno Sá <nuno.sa@analog.com>
Applied to the fixes-togreg branch of iio.git and marked for stable.
Thanks,
Jonathan
>
> > drivers/iio/gyro/adis16260.c | 3 +++
> > 1 file changed, 3 insertions(+)
> >
> > diff --git a/drivers/iio/gyro/adis16260.c b/drivers/iio/gyro/adis16260.c
> > index 586e6cfa14a9..91b9c5f18ec4 100644
> > --- a/drivers/iio/gyro/adis16260.c
> > +++ b/drivers/iio/gyro/adis16260.c
> > @@ -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
> > --
> > 2.43.0
> >
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-04-13 19:45 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-31 10:13 [PATCH] iio: gyro: adis16260: fix division by zero in write_raw Antoniu Miclaus
2026-03-31 11:04 ` Nuno Sá
2026-04-13 19:45 ` Jonathan Cameron
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.