Re: [PATCH 3/6] iio: proximity: sx9324: reject negative hysteresis values
From: Andy Shevchenko
Date: Tue Nov 17 2026 - 14:09:57 EST
On Tue, Nov 17, 2026 at 02:23:11AM +0530, Arnav Kapoor wrote:
> sx9324_write_hysteresis() copies the value into an unsigned int before
> comparing it with the threshold, so a negative value becomes a large
> one, passes the "val >= pthresh >> 2" check and sets the largest
> hysteresis instead of being rejected. Return -EINVAL for negative
> values.
As noticed earlier not all cases might have this issue, please elaborate if
this is for 32- and 64-bit cases or only for the former.
...
> unsigned int hyst, val = _val;
> int ret, pthresh;
>
> + if (_val < 0)
> + return -EINVAL;
Same (semantic) issue, you are checking variable after its use.
...
--
With Best Regards,
Andy Shevchenko