Re: [PATCH v6 2/8] iio: core: add fixed point parsing with 64-bit parts

From: Rodrigo Alencar

Date: Wed Feb 04 2026 - 04:43:10 EST


On 26/02/04 03:45AM, Andy Shevchenko wrote:
> On Fri, Jan 30, 2026 at 10:06:43AM +0000, Rodrigo Alencar via B4 Relay wrote:
>
> > Add iio_str_to_fixpoint64() function that leverages simple_strtoull()
> > to parse numbers from a string.
> > A helper function __iio_str_to_fixpoint64() replaces
> > __iio_str_to_fixpoint() implementation, extending its usage for
> > 64-bit fixed-point parsing.

...
> > +static ssize_t iio_safe_strntou64(const char *str, const char **endp,
> > + u64 *result, size_t max_chars)
> > +{
> > + u64 digit, acc = 0;
> > + ssize_t idx = 0;
> > +
> > + while (isdigit(str[idx]) && idx < max_chars) {
> > + digit = str[idx] - '0';
> > + if (unlikely(acc & (~0ull << 60))) {
> > + if (check_mul_overflow(acc, 10, &acc) ||
> > + check_add_overflow(acc, digit, &acc))
> > + return -ERANGE;
> > + } else {
> > + acc = acc * 10 + digit;
> > + }
> > + idx++;
> > + }
> > +
> > + *endp = str + idx;
> > + *result = acc;
> > + return idx;
> > +}
>
> There is a development in the parse_integer in the lib/. I reviewed that series
> and hopefully it will go in. With that done, we better reuse the lib/ function.
>
> https://lore.kernel.org/linux-hardening/20260202115451.290173-1-dmantipov@xxxxxxxxx/

In this patch, I see that it updates the overflow check, but I am not
seeing that function being exposed to other kernel modules.

--
Kind regards,

Rodrigo Alencar