Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Rodrigo Alencar via B4 Relay"
	<devnull+rodrigo.alencar.analog.com@kernel.org>
Cc: devicetree@vger.kernel.org, robh@kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH v13 02/12] iio: kstrtox: add local _parse_integer_limit_init() helper
Date: Sun, 17 May 2026 09:34:35 +0000	[thread overview]
Message-ID: <20260517093435.CAA2DC2BCB0@smtp.kernel.org> (raw)
In-Reply-To: <20260517-adf41513-iio-driver-v13-2-bb6e134a360f@analog.com>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Medium] Removal of a critical safety warning from the `_parse_integer_limit` documentation creates a trap for out-of-bounds memory access.
- [Low] Incorrect subsystem prefix 'iio:' for a core library patch.
--

commit 3edc3198f402bbf5139ee03843cbee9aeeecb619
Author: Rodrigo Alencar <rodrigo.alencar@analog.com>

iio: kstrtox: add local _parse_integer_limit_init() helper

This patch introduces _parse_integer_limit_init() to accept an initial
accumulated value for parsing 64-bit integers. It updates
_parse_integer_limit() to use this new helper with an initial value of 0,
and reorganizes its documentation.

> iio: kstrtox: add local _parse_integer_limit_init() helper

This isn't a bug, but since this patch modifies lib/kstrtox.c, which is a core
library file, should the prefix be "lib:" or "lib/kstrtox:" instead of "iio:"?

> diff --git a/lib/kstrtox.c b/lib/kstrtox.c
> index 97be2a39f5371..0705461f51c04 100644
> --- a/lib/kstrtox.c
> +++ b/lib/kstrtox.c

[ ... ]

> -/*
> - * Convert non-negative integer string representation in explicitly given radix
> - * to an integer. A maximum of max_chars characters will be converted.
> - *
> - * Return number of characters consumed maybe or-ed with overflow bit.
> - * If overflow occurs, result integer (incorrect) is still returned.
> - *
> - * Don't you dare use this function.
> - */
> -noinline
> -unsigned int _parse_integer_limit(const char *s, unsigned int base, unsigned long long *p,
> -				  size_t max_chars)

[ ... ]

> +/**
> + * _parse_integer_limit() - Convert integer string representation to an integer
> + *			    limiting the number of characters parsed.
> + * @s: The start of the string.
> + * @base: The number base to use.
> + * @p: Where to write the result of the conversion.
> + * @max_chars: Maximum amount of characters to consume.
> + *
> + * Convert non-negative integer string representation in explicitly given radix
> + * to an integer. A maximum of max_chars characters will be converted.
> + *
> + * Return: Number of characters consumed maybe or-ed with overflow bit.
> + *	   If overflow occurs, result integer (incorrect) is still returned.
> + */
> +noinline
> +unsigned int _parse_integer_limit(const char *s, unsigned int base,
> +				  unsigned long long *p, size_t max_chars)

Is it safe to remove the "Don't you dare use this function." warning?

Since this function returns the number of consumed characters bitwise-ORed with
the KSTRTOX_OVERFLOW flag, turning the comment into standard kernel-doc format
makes it look like an inviting API.

If a developer uses this and directly advances a pointer by the return value
without masking the overflow bit, could an integer overflow during parsing cause
the pointer to jump out-of-bounds?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260517-adf41513-iio-driver-v13-0-bb6e134a360f@analog.com?part=2

  reply	other threads:[~2026-05-17  9:34 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-17  9:13 [PATCH v13 00/12] ADF41513/ADF41510 PLL frequency synthesizers Rodrigo Alencar via B4 Relay
2026-05-17  9:13 ` [PATCH v13 01/12] dt-bindings: iio: frequency: add adf41513 Rodrigo Alencar via B4 Relay
2026-05-17  9:13 ` [PATCH v13 02/12] iio: kstrtox: add local _parse_integer_limit_init() helper Rodrigo Alencar via B4 Relay
2026-05-17  9:34   ` sashiko-bot [this message]
2026-05-17 12:19   ` Rodrigo Alencar
2026-05-17 13:53   ` Jonathan Cameron
2026-05-17  9:13 ` [PATCH v13 03/12] lib: kstrtox: add kstrtoudec64() and kstrtodec64() Rodrigo Alencar via B4 Relay
2026-05-17  9:13 ` [PATCH v13 04/12] lib: test-kstrtox: tests for kstrtodec64() and kstrtoudec64() Rodrigo Alencar via B4 Relay
2026-05-17  9:14 ` [PATCH v13 05/12] lib: math: div64: add div64_s64_rem() Rodrigo Alencar via B4 Relay
2026-05-17  9:14 ` [PATCH v13 06/12] iio: core: add decimal value formatting into 64-bit value Rodrigo Alencar via B4 Relay
2026-05-17 10:16   ` Andy Shevchenko
2026-05-17 10:44     ` Rodrigo Alencar
2026-05-17  9:14 ` [PATCH v13 07/12] iio: test: iio-test-format: add test case for decimal format Rodrigo Alencar via B4 Relay
2026-05-17  9:30   ` sashiko-bot
2026-05-17 13:56   ` Jonathan Cameron
2026-05-17  9:14 ` [PATCH v13 08/12] iio: frequency: adf41513: driver implementation Rodrigo Alencar via B4 Relay
2026-05-17  9:49   ` sashiko-bot
2026-05-17 11:56   ` Rodrigo Alencar
2026-05-17 14:05   ` Jonathan Cameron
2026-05-17  9:14 ` [PATCH v13 09/12] iio: frequency: adf41513: handle LE synchronization feature Rodrigo Alencar via B4 Relay
2026-05-17  9:14 ` [PATCH v13 10/12] iio: frequency: adf41513: features on frequency change Rodrigo Alencar via B4 Relay
2026-05-17  9:54   ` sashiko-bot
2026-05-17  9:14 ` [PATCH v13 11/12] docs: iio: add documentation for adf41513 driver Rodrigo Alencar via B4 Relay
2026-05-17  9:14 ` [PATCH v13 12/12] Documentation: ABI: testing: add common ABI file for iio/frequency Rodrigo Alencar via B4 Relay
2026-05-17 14:08 ` [PATCH v13 00/12] ADF41513/ADF41510 PLL frequency synthesizers Jonathan Cameron

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260517093435.CAA2DC2BCB0@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=devnull+rodrigo.alencar.analog.com@kernel.org \
    --cc=robh@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox