Re: [PATCH] iio: accel: fxls8962af: clamp the device-reported FIFO sample count

From: Andy Shevchenko

Date: Mon Jun 15 2026 - 06:17:23 EST


On Sun, Jun 14, 2026 at 02:43:37PM +0100, Jonathan Cameron wrote:
> On Sat, 13 Jun 2026 03:13:19 -0500
> Bryam Vargas via B4 Relay <devnull+hexlabsecurity.proton.me@xxxxxxxxxx> wrote:

...

> > Fixes: 79e3a5bdd9ef ("iio: accel: fxls8962af: add hw buffered sampling")
>
> This is hardening against broken devices. Nice to have, but not a fix and
> not back port material. In general we do harden against the simple cases
> but to catch the more complex interactions would require both a hard to do
> audit and significant extra code.

On top of that using min_t(u8, ...) is prone to more interesting errors,
so one basically should immediately raise a red flag here. As Jonathan
said, use min() or even clamp() as the Subject states.

foo = clamp(bar, 0, GOO);
if (!foo)
return 0;

> So nice to have this but not a fix.


--
With Best Regards,
Andy Shevchenko