From: "Nuno Sá" <noname.nuno@gmail.com>
To: Antoniu Miclaus <antoniu.miclaus@analog.com>
Cc: "Lars-Peter Clausen" <lars@metafoo.de>,
"Michael Hennerich" <Michael.Hennerich@analog.com>,
"Jonathan Cameron" <jic23@kernel.org>,
"David Lechner" <dlechner@baylibre.com>,
"Nuno Sá" <nuno.sa@analog.com>,
"Greg Kroah-Hartman" <gregkh@suse.de>,
"Barry Song" <Barry.Song@analog.com>,
linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] iio: gyro: adis16260: fix division by zero in write_raw
Date: Tue, 31 Mar 2026 12:04:45 +0100 [thread overview]
Message-ID: <acuqM42TLd4edTWZ@nsa> (raw)
In-Reply-To: <20260331101300.15853-1-antoniu.miclaus@analog.com>
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
>
prev parent reply other threads:[~2026-03-31 11:04 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
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á [this message]
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=acuqM42TLd4edTWZ@nsa \
--to=noname.nuno@gmail.com \
--cc=Barry.Song@analog.com \
--cc=Michael.Hennerich@analog.com \
--cc=antoniu.miclaus@analog.com \
--cc=dlechner@baylibre.com \
--cc=gregkh@suse.de \
--cc=jic23@kernel.org \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nuno.sa@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