From: sashiko-bot@kernel.org
To: "Birk Skyum" <birk.skyum@pm.me>
Cc: linux-gpio@vger.kernel.org
Subject: Re: [PATCH] reset: gpio: Keep reset-gpio device under the GPIO controller device
Date: Tue, 01 Dec 2026 16:50:08 +0000 [thread overview]
Message-ID: <sashiko-outbox-243738@kernel.org> (raw)
In-Reply-To: <20261201-reset-gpio-parent-devlink-v1-1-5195e8b377c4@pm.me>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [High] reset: gpio: reparenting breaks gpio_shared_dev_is_reset_gpio()
match
It also noticed 1 related pre-existing issue this patch does not
introduce:
- [High] reset: spurious WARN and use-after-free on
reset_create_gpio_aux_device() failure [1]
--
commit 890ede247418cae89ef97a10e0ba05a7fd77ed0d
Author: Birk Skyum <birk.skyum@pm.me>
reset: gpio: Keep reset-gpio device under the GPIO controller device
This commit parents reset-gpio auxiliary devices under the GPIO controller
device instead of the gpiochip device and adds a DL_FLAG_AUTOPROBE_CONSUMER
device link so the reset-gpio device unbinds and re-probes across GPIO
controller driver unbind and rebind cycles.
> diff --git a/drivers/reset/core.c b/drivers/reset/core.c
> index 38e189d04d09b..09bb7784c877b 100644
> --- a/drivers/reset/core.c
> +++ b/drivers/reset/core.c
[ ... ]
> @@ -1070,9 +1070,20 @@ static int __reset_add_reset_gpio_device(struct fwnode_handle *fwnode,
> }
>
> lflags = GPIO_PERSISTENT | (flags & GPIO_ACTIVE_LOW);
> - parent = gpio_device_to_device(gdev);
> + gdev_dev = gpio_device_to_device(gdev);
> properties[prop++] = PROPERTY_ENTRY_STRING("compatible", "reset-gpio");
> - properties[prop++] = PROPERTY_ENTRY_GPIO("reset-gpios", parent->fwnode, offset, lflags);
> + properties[prop++] = PROPERTY_ENTRY_GPIO("reset-gpios", gdev_dev->fwnode, offset, lflags);
> +
> + /*
> + * The reset-gpio device is never removed, but the GPIO device goes
> + * away whenever the GPIO controller's driver unbinds, for example the
> + * LPASS pin controller when the audio DSP restarts. A reset-gpio
> + * device left under the old GPIO device can never bind again
> + * ("driver_sysfs_add failed"). Put it under the device that provides
> + * the GPIO controller instead, which stays, and link it to that
> + * device below so it follows the controller's driver.
> + */
> + parent = gdev_dev->parent ?: gdev_dev;
[Severity: High]
Does reparenting the reset-gpio auxiliary device to gdev_dev->parent break
shared GPIO lookup in gpio_shared_dev_is_reset_gpio() when the gpio_chip
has its own fwnode?
In gpiolib-shared, entry->fwnode is the firmware node of the GPIO
controller matched against &gdev->dev (which uses gc->fwnode when set),
and gpio_shared_dev_is_reset_gpio() expects the reset-gpio device's parent
to match that fwnode:
drivers/gpio/gpiolib-shared.c:gpio_shared_dev_is_reset_gpio() {
...
/*
* Parent of the reset-gpio auxiliary device is the GPIO chip whose
* fwnode we stored in the entry structure.
*/
if (!device_match_fwnode(parent, entry->fwnode))
return false;
...
}
On controllers where gc->fwnode differs from dev_fwnode(gc->parent) (such
as multi-bank pin controllers with per-bank child DT nodes),
device_match_fwnode() now checks gdev_dev->parent instead of gdev_dev and
returns false. When reset_gpio_probe() requests the shared reset GPIO,
gpio_shared_add_proxy_lookup() then hits WARN_ON(1) and fails the probe
with -ENOENT.
>
> /* Not freed on success, because it is persisent subsystem data. */
> rgpio_dev = kzalloc_obj(*rgpio_dev);
> @@ -1097,6 +1108,17 @@ static int __reset_add_reset_gpio_device(struct fwnode_handle *fwnode,
> if (ret)
> goto err_del_swnode;
[Severity: High]
This problem wasn't introduced by this patch, but if
reset_create_gpio_aux_device() fails in __auxiliary_device_add() after
auxiliary_device_init() has succeeded, can error cleanup trigger a
spurious WARN and a use-after-free [1]?
drivers/reset/core.c:reset_create_gpio_aux_device() {
...
adev->dev.release = reset_gpio_aux_device_release;
...
ret = auxiliary_device_init(adev);
if (ret) {
ida_free(&reset_gpio_ida, id);
return ret;
}
ret = __auxiliary_device_add(adev, "reset");
if (ret) {
auxiliary_device_uninit(adev);
ida_free(&reset_gpio_ida, id);
return ret;
}
}
auxiliary_device_uninit() calls put_device(), which invokes
reset_gpio_aux_device_release() and triggers its unconditional WARN(1,
...) without freeing rgpio_dev. __reset_add_reset_gpio_device() then
jumps to err_del_swnode and runs kfree(rgpio_dev) outside the device
release callback, causing a use-after-free in kobject_delayed_cleanup()
when CONFIG_DEBUG_KOBJECT_RELEASE is enabled.
[1] https://sashiko.dev/#/bug/linux-c613c5b7-1804-46c9-9911-ed5179103296
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261201-reset-gpio-parent-devlink-v1-1-5195e8b377c4@pm.me?part=1
next prev parent reply other threads:[~2026-12-01 16:50 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-01 16:28 [PATCH] reset: gpio: Keep reset-gpio device under the GPIO controller device Birk Skyum via B4 Relay
2026-12-01 16:50 ` sashiko-bot [this message]
2026-12-01 16:57 ` Philipp Zabel
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-243738@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=birk.skyum@pm.me \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox