Re: [PATCH v6 1/5] lib: fix _parse_integer_limit() to handle overflow
From: Dmitry Antipov
Date: Thu Feb 12 2026 - 06:19:42 EST
On Tue, 2026-02-10 at 09:36 +0200, Andy Shevchenko wrote:
> I don't see how max_chars is used. With that said, I would rather see the usual
> way of expressing the condition in the for-loop:
>
> for (rv = 0; rv < max_chars; rv++, s++) {
This will break the loop (and so stop consuming characters) if KSTRTOX_OVERFLOW
bit is set.
> > + if (likely(res != ULLONG_MAX)) {
>
> Have you seen David's question about these checks?
> Maybe I missed your answer...
>
> > + if (unlikely(res & (~0ull << 60))) {
The first check may be dropped indeed (assuming check_mul_overflow(ULLONG_MAX, a, b)
and check_add_overflow(ULLONG_MAX, a, b) always signals an overflow).
Dmitry