From: sashiko-bot@kernel.org
To: "Prasanth Kumar Padarthi" <prasanth.padarthi10@gmail.com>
Cc: linux-gpio@vger.kernel.org
Subject: Re: [PATCH v3] pinctrl: aspeed: Hand over global GPIOP passthrough to local mux controls
Date: Thu, 05 Nov 2026 15:33:16 +0000 [thread overview]
Message-ID: <sashiko-outbox-199315@kernel.org> (raw)
In-Reply-To: <20261105152348.8567-1-prasanth.padarthi10@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] pinctrl: aspeed: use-after-free on unbind in aspeed_g6_pinctrl_probe()
--
commit 7926ad91b4f1741a83b80da360b9a845357a5376
Author: Prasanth Kumar Padarthi <prasanth.padarthi10@gmail.com>
pinctrl: aspeed: Hand over global GPIOP passthrough to local mux controls
This commit transfers global GPIOP0-P5 passthrough selections in SCU510 and
SCU51C to per-pin mux controls in SCU4BC during probe, and blocks GPIO and
mux requests on GPIOP0-P5 if the handover fails.
> diff --git a/drivers/pinctrl/aspeed/pinctrl-aspeed-g6.c b/drivers/pinctrl/aspeed/pinctrl-aspeed-g6.c
> index 85d6640ff4c4e..be22a918420df 100644
> --- a/drivers/pinctrl/aspeed/pinctrl-aspeed-g6.c
> +++ b/drivers/pinctrl/aspeed/pinctrl-aspeed-g6.c
[ ... ]
> @@ -2778,15 +2827,103 @@ static const struct pinctrl_desc aspeed_g6_pinctrl_desc = {
[ ... ]
> static int aspeed_g6_pinctrl_probe(struct platform_device *pdev)
> {
> - int i;
> + struct aspeed_g6_probe_data *g6;
> + struct regmap *scu;
> + int i, ret;
> +
> + if (!pdev->dev.parent)
> + return -ENODEV;
> + scu = syscon_node_to_regmap(pdev->dev.parent->of_node);
> + if (IS_ERR(scu))
> + return dev_err_probe(&pdev->dev, PTR_ERR(scu),
> + "No SCU regmap for THRU handover\n");
> +
> + g6 = devm_kzalloc(&pdev->dev, sizeof(*g6), GFP_KERNEL);
> + if (!g6)
> + return -ENOMEM;
> + memcpy(&g6->pdata, &aspeed_g6_pinctrl_data, sizeof(g6->pdata));
> +
> + ret = aspeed_g6_thru_handover(scu);
> + if (ret == -EPROBE_DEFER)
> + return ret;
> + if (ret) {
> + g6->thru_error = ret;
> + dev_warn(&pdev->dev,
> + "THRU handover failed (%d); GPIOP0-P5 mux requests blocked\n",
> + ret);
> + }
>
> for (i = 0; i < ARRAY_SIZE(aspeed_g6_pins); i++)
> aspeed_g6_pins[i].number = i;
>
> return aspeed_pinctrl_probe(pdev, &aspeed_g6_pinctrl_desc,
> - &aspeed_g6_pinctrl_data);
> + &g6->pdata);
[Severity: High]
Can this cause a use-after-free of g6 if the device is unbound?
In aspeed_g6_pinctrl_probe(), g6 is allocated with devm_kzalloc() and
&g6->pdata is passed to aspeed_pinctrl_probe(). However,
drivers/pinctrl/aspeed/pinctrl-aspeed.c:aspeed_pinctrl_probe() registers the
controller with the unmanaged pinctrl_register() helper:
drivers/pinctrl/aspeed/pinctrl-aspeed.c:aspeed_pinctrl_probe() {
...
pctl = pinctrl_register(pdesc, &pdev->dev, pdata);
...
}
Previously, aspeed_g6_pinctrl_probe() passed the static
aspeed_g6_pinctrl_data structure, which remained valid for the lifetime of
the kernel. Because aspeed_g6_pinctrl_driver does not define a .remove
callback to call pinctrl_unregister() and does not set .suppress_bind_attrs,
unbinding the platform device via sysfs frees g6 via devres while the
pinctrl_dev remains registered with driver_data pointing to &g6->pdata.
Subsequent calls to aspeed_g6_set_mux(), aspeed_g6_gpio_request_enable(),
other pinctrl callbacks, or pinctrl debugfs entries will then dereference the
freed g6 structure.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261105152348.8567-1-prasanth.padarthi10@gmail.com?part=1
next prev parent reply other threads:[~2026-11-05 15:33 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-15 3:51 [RFC PATCH] pinctrl: aspeed: Handle GPIOZ6 pass-through strap on GPIO requests Prasanth Kumar Padarthi
2026-10-15 4:01 ` sashiko-bot
2026-10-15 4:09 ` Prasanth
2026-10-20 12:52 ` Prasanth
2026-10-22 2:43 ` [RFC PATCH v2 0/1] AST2600 global GPIOP passthrough handover experiment Prasanth Kumar Padarthi
2026-10-22 2:43 ` [RFC PATCH v2] pinctrl: aspeed: Hand over global GPIOP passthrough to local mux controls Prasanth Kumar Padarthi
2026-11-05 15:23 ` [PATCH v3] " Prasanth Kumar Padarthi
2026-11-05 15:33 ` sashiko-bot [this message]
2026-11-05 17:09 ` Prasanth
2026-11-06 2:28 ` [PATCH v4 0/2] Aspeed GPIOP handover with managed controller lifetime Prasanth Kumar Padarthi
2026-11-06 2:29 ` Prasanth Kumar Padarthi
2026-11-06 2:29 ` [PATCH v4 1/2] pinctrl: aspeed: Use managed pinctrl registration Prasanth Kumar Padarthi
2026-11-06 6:13 ` Andrew Jeffery
2026-11-06 2:29 ` [PATCH v4 2/2] pinctrl: aspeed: Hand over global GPIOP passthrough to local mux controls Prasanth Kumar Padarthi
2026-11-06 10:54 ` Andrew Jeffery
2026-11-07 0:50 ` Prasanth
2026-11-06 5:25 ` [PATCH v4 0/2] Aspeed GPIOP handover with managed controller lifetime Andrew Jeffery
2026-11-04 12:19 ` [RFC PATCH] pinctrl: aspeed: Handle GPIOZ6 pass-through strap on GPIO requests Linus Walleij
2026-11-05 3:36 ` Prasanth
2026-11-05 13:27 ` Linus Walleij
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-199315@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-gpio@vger.kernel.org \
--cc=prasanth.padarthi10@gmail.com \
--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.