Re: [PATCH] iio: core: fix signed integer overflow in
From: Arnav Kapoor
Date: Thu Oct 22 2026 - 04:28:26 EST
(Resending with the list Cc'd, sorry for the duplicate, Andy.)
On Thu, Oct 22, 2026 at 10:08:10AM +0300, Andy Shevchenko wrote:
> This needs a Fixes tag, otherwise it probably won't needed as Rodrigo working
> towards tons of improvements in this area.
Will add:
Fixes: 6807d7211327 ("iio: Factor out fixed point number parsing into its own function")
> OTOH, Rodrigo's test cases might be good as part of this fix as well.
As far as I can see, Rodrigo's tests in the E notation RFC exercise
kstrtodec64() in lib/test-kstrtox.c, so they won't cover the current
parser. I'd rather keep the fix small for backporting and send KUnit
cases for iio_str_to_fixpoint() as a separate patch, if that's OK.
> Wow, what's wrong with INT_MIN?
Nothing, it was just clumsy. In v2 the sign is applied while
accumulating, so INT_MIN falls out naturally and the limit goes away.
> What's the point in changing this line?
> Why do you need explicit castings?
None, both dropped.
> Do you know about APIs in overflow.h? I think you wanted to use something
> from there.
Yes, v2 uses check_mul_overflow() and check_add_overflow() and keeps
the variables as int, so the s64 and the declaration reordering are
gone too.
I'll send v2 shortly.
Thanks,
Arnav