mirror of
https://github.com/torvalds/linux.git
synced 2026-06-04 04:23:35 +02:00
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: 64b3d8b1b0 ("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>
This commit is contained in:
parent
0d42e2c0bd
commit
5aba4f94b2
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user