All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Gary Wang" <is0124@gmail.com>
Cc: linux-gpio@vger.kernel.org
Subject: Re: [PATCH 4/5] pinctrl: upboard: fix I2C pinmux-select set CPLD GPIO OUT not function mode
Date: Mon, 23 Nov 2026 15:26:25 +0000	[thread overview]
Message-ID: <sashiko-outbox-229555@kernel.org> (raw)
In-Reply-To: <20261123-upboard-pinctrl-add-intc1057-intc105e-support-v1-4-f2322a91686d@gmail.com>

Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [High] pinctrl: upboard: missing Signed-off-by trailer in commit
  message
- [High] pinctrl: upboard: NULL modes deref in upboard_pinctrl_set_mux()
  on mode 0
--

commit 9be514c1a4ebbf98ef179a29ba2bf1adb01fa558
Author: Gary Wang <is0124@gmail.com>

> pinctrl: upboard: fix I2C pinmux-select set CPLD GPIO OUT not function mode
>
> The CPLD I2C pin mode setting following uart & spi used modes array
> on device AANT0F04.
>
> CC: stable@vger.kernel.org
> Fixes: dca2f73cf19f ("pinctrl: Add pin controller driver for AAEON UP boards")

[Severity: High]
The commit message is missing a Signed-off-by: trailer from the patch
author, as required by Documentation/process/submitting-patches.rst.

> diff --git a/drivers/pinctrl/pinctrl-upboard.c b/drivers/pinctrl/pinctrl-upboard.c
> index b9af6dd93c343..66c1c3e3bfe08 100644
> --- a/drivers/pinctrl/pinctrl-upboard.c
> +++ b/drivers/pinctrl/pinctrl-upboard.c
> @@ -225,11 +225,21 @@ static const unsigned int upboard_up_i2c0_pins[] = {
>  	UPBOARD_UP_BIT_TO_PIN(I2C0_SDA),
>  };
>  
> +static const enum upboard_pin_mode upboard_up_i2c0_modes[] = {
> +	UPBOARD_PIN_MODE_FUNCTION,
> +	UPBOARD_PIN_MODE_FUNCTION,
> +};
> +
>  static const unsigned int upboard_up_i2c1_pins[] = {
>  	UPBOARD_UP_BIT_TO_PIN(I2C1_SCL),
>  	UPBOARD_UP_BIT_TO_PIN(I2C1_SDA),
>  };
>  
> +static const enum upboard_pin_mode upboard_up_i2c1_modes[] = {
> +	UPBOARD_PIN_MODE_FUNCTION,
> +	UPBOARD_PIN_MODE_FUNCTION,
> +};
> +
>  static const unsigned int upboard_up_spi2_pins[] = {
>  	UPBOARD_UP_BIT_TO_PIN(SPI_MOSI),
>  	UPBOARD_UP_BIT_TO_PIN(SPI_MISO),
> @@ -289,8 +299,8 @@ static const unsigned int upboard_up_adc0_pins[] = {
>  
>  static const struct upboard_pingroup upboard_up_pin_groups[] = {
>  	UPBOARD_PINGROUP("uart1_grp", upboard_up_uart1_pins, &upboard_up_uart1_modes[0]),
> -	UPBOARD_PINGROUP("i2c0_grp", upboard_up_i2c0_pins, UPBOARD_PIN_MODE_GPIO_OUT),
> -	UPBOARD_PINGROUP("i2c1_grp", upboard_up_i2c1_pins, UPBOARD_PIN_MODE_GPIO_OUT),
> +	UPBOARD_PINGROUP("i2c0_grp", upboard_up_i2c0_pins, &upboard_up_i2c0_modes[0]),
> +	UPBOARD_PINGROUP("i2c1_grp", upboard_up_i2c1_pins, &upboard_up_i2c1_modes[0]),
>  	UPBOARD_PINGROUP("spi2_grp", upboard_up_spi2_pins, &upboard_up_spi2_modes[0]),
>  	UPBOARD_PINGROUP("i2s0_grp", upboard_up_i2s0_pins, &upboard_up_i2s0_modes[0]),
>  	UPBOARD_PINGROUP("pwm0_grp", upboard_up_pwm0_pins, UPBOARD_PIN_MODE_GPIO_OUT),

[Severity: High]
Are upboard_up_i2c0_modes[] and upboard_up_i2c1_modes[] working around a
NULL pointer dereference in upboard_pinctrl_set_mux() when a pin group uses
a scalar UPBOARD_PIN_MODE_FUNCTION?

UPBOARD_PIN_MODE_FUNCTION is 0, and UPBOARD_PINGROUP() sets .mode = m and
.modes = NULL when passed a scalar enum upboard_pin_mode.  Because
upboard_pinctrl_set_mux() tests .mode instead of .modes:

drivers/pinctrl/pinctrl-upboard.c:upboard_pinctrl_set_mux() {
	...
	for (i = 0; i < grp->grp.npins; i++) {
		mode = upgroups[group_selector].mode ?: upgroups[group_selector].modes[i];
	...
}

any group configured with scalar UPBOARD_PIN_MODE_FUNCTION has .mode == 0
and .modes == NULL, causing upboard_pinctrl_set_mux() to dereference NULL
at .modes[i].  The UP2 table already defines i2c0_grp and i2c1_grp with
scalar UPBOARD_PIN_MODE_FUNCTION in upboard_up2_pin_groups[], so muxing I2C
on UP2 still triggers this NULL pointer dereference.

Instead of adding uniform mode arrays (which also lack the static_assert()
size checks used for the other mode arrays), should
upboard_pinctrl_set_mux() check upgroups[group_selector].modes ?
upgroups[group_selector].modes[i] : upgroups[group_selector].mode so
i2c0_grp and i2c1_grp can pass UPBOARD_PIN_MODE_FUNCTION directly?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261123-upboard-pinctrl-add-intc1057-intc105e-support-v1-0-f2322a91686d@gmail.com?part=4

  reply	other threads:[~2026-11-23 15:26 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-23 15:16 [PATCH 0/5] upboard pinctrl support for device id INTC1055 & INTC1057 & INTC105E Gary Wang
2026-11-23 15:16 ` [PATCH 1/5] pinctrl: tigerlake: add ish_uart groups and functions for INTC1055 Gary Wang
2026-11-23 15:25   ` sashiko-bot
2026-11-23 15:16 ` [PATCH 2/5] pinctrl: alderlake: add some groups and functions for INTC1057 Gary Wang
2026-11-23 15:22   ` sashiko-bot
2026-11-23 15:16 ` [PATCH 3/5] pinctrl: meteorlake: add some groups and functions for INTC105E Gary Wang
2026-11-23 15:21   ` sashiko-bot
2026-11-23 15:16 ` [PATCH 4/5] pinctrl: upboard: fix I2C pinmux-select set CPLD GPIO OUT not function mode Gary Wang
2026-11-23 15:26   ` sashiko-bot [this message]
2026-11-23 20:01   ` Andy Shevchenko
2026-11-23 20:39     ` GaryWang
2026-12-01  8:44       ` Linus Walleij
2026-11-24  9:17   ` Thomas Richard
2026-11-24 10:18     ` GaryWang
2026-11-23 15:16 ` [PATCH 5/5] pinctrl: upboard: add device id INTC1055 & INTC1057 & INTC105E based UP boards support Gary Wang
2026-11-23 15:28   ` sashiko-bot
2026-11-23 19:58 ` [PATCH 0/5] upboard pinctrl support for device id INTC1055 & INTC1057 & INTC105E Andy Shevchenko
2026-11-23 19:59   ` Andy Shevchenko

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=sashiko-outbox-229555@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=is0124@gmail.com \
    --cc=linux-gpio@vger.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.