diff options
| author | Antoniu Miclaus <antoniu.miclaus@analog.com> | 2026-04-01 14:08:29 +0300 |
|---|---|---|
| committer | Jonathan Cameron <jic23@kernel.org> | 2026-04-28 18:36:09 +0300 |
| commit | 5aba4f94b225617a55fed442a70329b2ee19c0a5 (patch) | |
| tree | 0329dc45d77b6a57d7879dc20307fa4f1a7ac54e | |
| parent | 0d42e2c0bd6ceb89e44c6e065f9bdf9b1df3ef0c (diff) | |
| download | linux-5aba4f94b225617a55fed442a70329b2ee19c0a5.tar.xz | |
iio: chemical: scd30: fix division by zero in write_raw
Add a zero check for val2 before using it as a divisor when setting the
sampling frequency. A user writing a zero fractional part to the
sampling_frequency sysfs attribute triggers a division by zero in the
kernel.
Fixes: 64b3d8b1b0f5 ("iio: chemical: scd30: add core driver")
Signed-off-by: Antoniu Miclaus <antoniu.miclaus@analog.com>
Cc: <Stable@vger.kernel.org>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>
| -rw-r--r-- | drivers/iio/chemical/scd30_core.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/iio/chemical/scd30_core.c b/drivers/iio/chemical/scd30_core.c index a665fcb78806..11d6bc1b63e6 100644 --- a/drivers/iio/chemical/scd30_core.c +++ b/drivers/iio/chemical/scd30_core.c @@ -256,7 +256,7 @@ static int scd30_write_raw(struct iio_dev *indio_dev, struct iio_chan_spec const guard(mutex)(&state->lock); switch (mask) { case IIO_CHAN_INFO_SAMP_FREQ: - if (val) + if (val || !val2) return -EINVAL; val = 1000000000 / val2; |
