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

From: Jonathan Cameron

Date: Mon May 11 2026 - 08:04:59 EST


On Sat, 9 May 2026 19:47:53 -0500
Maxwell Doose <m32285159@xxxxxxxxx> wrote:

> On Sat, May 9, 2026 at 4:53 PM Maxwell Doose <m32285159@xxxxxxxxx> wrote:
> >
> > On Sat, May 9, 2026 at 4:47 PM David Lechner <dlechner@xxxxxxxxxxxx> wrote:
> > > On 5/9/26 4:36 PM, Maxwell Doose wrote:
> > > > Yes, we're reading over either SPI or I2C, the sensor supports both.
> > > > Hardware failure is going to be the most likely cause of this path
> > > > being taken, but I could also see some sort of noise on the bus being
> > > > the cause. Perhaps we change it to:
> > > >
> > > > /* Likely taken if hardware is failing or noise on bus */
> > > >
> > > > best regards,
> > > > max
> > >
> > > Sounds OK.
> > >
> > > A more verbose alternative:
> > >
> > > /*
> > > * Value of 0 is unexpected, but could happen, e.g. due to
> > > * hardware failure.
> > > */
> >
> > Also works for me, I'm impartial to either. Perhaps we can see if
> > Jonathan is willing to change it during merge or if I'll have to go
> > back and change it in a v2.
> >
> > best regards,
> > max
>
> Also maybe we update to use dev_err_ratelimited(), sashiko has a good
> point here:
>
> https://sashiko.dev/#/patchset/20260509211921.84969-1-m32285159%40gmail.com
>
Do we care for something that is going to be a very rare hardware failure?
That's one interesting attack vector. I suppose maybe they have another
exploit that lets them trip the scd30 into an odd state.

Ah well, doesn't do much harm to rate limit it I guess.

Jonathan

> best regards,
> max