From: sashiko-bot@kernel.org
To: "Adrian Ambrozewicz" <aambrozewicz@nvidia.com>
Cc: linux-gpio@vger.kernel.org, linux-usb@vger.kernel.org
Subject: Re: [PATCH 06/11] gpio: Add NVIDIA LSTP GPIO driver
Date: Mon, 12 Oct 2026 17:53:50 +0000 [thread overview]
Message-ID: <sashiko-outbox-168501@kernel.org> (raw)
In-Reply-To: <20261012-lstp-usb-adapter-v1-6-aambrozewicz@nvidia.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] core: module unload race in lstp_gpio_leds_release() waking module_exit
--
commit 4aeddbd8eb4f935f2de9273a79a09c2407988002
Author: Adrian Ambrozewicz <aambrozewicz@nvidia.com>
gpio: Add NVIDIA LSTP GPIO driver
Add a driver for the GPIO channels of NVIDIA LSTP USB adapters. Each
channel is registered as a GPIO chip with an interrupt controller for
its pins. Pins the firmware reports as LEDs are handed to the LED driver
as an auxiliary device.
> diff --git a/drivers/gpio/gpio-lstp.c b/drivers/gpio/gpio-lstp.c
> new file mode 100644
> index 0000000000000..cc988a09582b0
> --- /dev/null
> +++ b/drivers/gpio/gpio-lstp.c
[ ... ]
> +static void lstp_gpio_leds_release(struct device *dev)
> +{
> + struct lstp_leds *leds = container_of(to_auxiliary_dev(dev), struct lstp_leds, auxdev);
> + struct device *parent = leds->ch->dev;
> +
> + kfree(leds);
> + put_device(parent);
> + if (atomic_dec_and_test(&lstp_gpio_live_leds))
> + wake_up_var(&lstp_gpio_live_leds);
> +}
[Severity: High]
Does this create a module unload race condition?
If a user-space process holds an active sysfs reference to the LED auxiliary
device, the device release callback is delayed until userspace drops its
reference (for example, closing a file descriptor). By this time, the rmmod
command could be executing and waiting in lstp_gpio_module_exit().
When lstp_gpio_leds_release() wakes up the module_exit waiter, the rmmod
thread finishes and the kernel unmaps the module's text memory. However, the
thread running the release callback is still executing the epilogue of
lstp_gpio_leds_release(), which resides in this module.
Returning to unmapped memory causes a kernel panic. A device release function
must not wake the module_exit thread that unloads its own code.
[ ... ]
> +/* The unregister unbinds every channel, which deletes its LED child. */
> +static void __exit lstp_gpio_module_exit(void)
> +{
> + lstp_auxiliary_driver_unregister(&lstp_gpio_drv);
> + wait_var_event(&lstp_gpio_live_leds, !atomic_read(&lstp_gpio_live_leds));
> +}
> +module_exit(lstp_gpio_module_exit);
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261012-lstp-usb-adapter-v1-0-aambrozewicz@nvidia.com?part=6
next prev parent reply other threads:[~2026-10-12 17:53 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-12 17:35 [PATCH 00/11] Add NVIDIA LSTP USB adapter drivers Adrian Ambrozewicz
2026-10-12 17:35 ` [PATCH 01/11] dt-bindings: gpio: Add NVIDIA LSTP GPIO Adrian Ambrozewicz
2026-10-12 17:43 ` sashiko-bot
2026-10-13 6:09 ` Krzysztof Kozlowski
2026-10-12 17:36 ` [PATCH 02/11] dt-bindings: i2c: Add NVIDIA LSTP I2C Adrian Ambrozewicz
2026-10-12 17:41 ` sashiko-bot
2026-10-13 6:11 ` Krzysztof Kozlowski
2026-10-12 17:36 ` [PATCH 03/11] dt-bindings: spi: Add NVIDIA LSTP SPI Adrian Ambrozewicz
2026-10-12 17:46 ` sashiko-bot
2026-10-13 6:11 ` Krzysztof Kozlowski
2026-10-12 17:36 ` [PATCH 04/11] dt-bindings: usb: Add NVIDIA LSTP USB adapter Adrian Ambrozewicz
2026-10-12 17:47 ` sashiko-bot
2026-10-13 6:13 ` Krzysztof Kozlowski
2026-10-13 6:17 ` Krzysztof Kozlowski
2026-10-12 17:36 ` [PATCH 05/11] usb: misc: Add NVIDIA LSTP USB adapter driver Adrian Ambrozewicz
2026-10-12 17:51 ` sashiko-bot
2026-10-12 17:36 ` [PATCH 06/11] gpio: Add NVIDIA LSTP GPIO driver Adrian Ambrozewicz
2026-10-12 17:53 ` sashiko-bot [this message]
2026-10-12 17:36 ` [PATCH 07/11] leds: Add NVIDIA LSTP LED driver Adrian Ambrozewicz
2026-10-12 17:46 ` sashiko-bot
2026-10-12 17:36 ` [PATCH 08/11] i2c: Add NVIDIA LSTP I2C driver Adrian Ambrozewicz
2026-10-12 17:49 ` sashiko-bot
2026-10-12 17:36 ` [PATCH 09/11] spi: Add NVIDIA LSTP SPI driver Adrian Ambrozewicz
2026-10-12 17:45 ` sashiko-bot
2026-10-12 17:36 ` [PATCH 10/11] tty: Add NVIDIA LSTP UART driver Adrian Ambrozewicz
2026-10-12 17:50 ` sashiko-bot
2026-10-13 5:49 ` Jiri Slaby
2026-10-12 17:36 ` [PATCH 11/11] ipmi: Add NVIDIA LSTP IPMI BMC driver Adrian Ambrozewicz
2026-10-12 17:51 ` sashiko-bot
2026-10-12 21:10 ` Corey Minyard
2026-10-13 11:37 ` [PATCH 00/11] Add NVIDIA LSTP USB adapter drivers Greg Kroah-Hartman
2026-10-13 11:39 ` Greg Kroah-Hartman
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-168501@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=aambrozewicz@nvidia.com \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-usb@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.