Re: [PATCH v2] iio: chemical: scd30: Prevent potential divide-by-zero errors

From: Andy Shevchenko

Date: Mon May 11 2026 - 06:50:02 EST


On Sun, May 10, 2026 at 03:21:56PM -0500, Maxwell Doose wrote:
> In scd30_read_raw, the current value of tmp in the

We refer to the functions as func().

> IIO_CHAN_INFO_SAMP_FREQ case is unchecked. Add checking to see if the
> value we got was 0 to prevent a divide-by-zero error.
>
> A similar case has also been found in scd30_write_raw(), also in the
> IIO_CHAN_INFO_SAMP_FREQ case, where the value of val2 was unchecked.
> Add checking for that variable as well and return -EINVAL if it's 0.

...

> + /*
> + * Value of 0 is unexpected but possible if hardware is failing
> + * or noise on data bus

Respect English punctuation. Here the period at the end is missing.

> + */

> + dev_err_ratelimited(&indio_dev->dev,
> + "Invalid measurement interval 0 received\n");

I believe here is missing colon.

"Invalid measurement: interval 0 received\n");

> + return -EIO;
> + }

--
With Best Regards,
Andy Shevchenko