From: sashiko-bot@kernel.org
To: "Eliav Farber" <farbere@amazon.com>
Cc: dmitry.torokhov@gmail.com, linux-input@vger.kernel.org
Subject: Re: [PATCH v4 05/13] gpio: adp5585: use devm_blocking_notifier_chain_register()
Date: Sun, 26 Jul 2026 10:27:53 +0000 [thread overview]
Message-ID: <20260726102753.B172C1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260726101739.33170-6-farbere@amazon.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] Use-after-free of the gpiochip's IRQ domain during device unbinding due to incorrect devres registration order.
--
--- Patch [5]: [PATCH v4 05/13] gpio: adp5585: use devm_blocking_notifier_chain_register() ---
commit 44c510dbb3ca8a6273606da82607128231bd2e31
Author: Eliav Farber <farbere@amazon.com>
gpio: adp5585: use devm_blocking_notifier_chain_register()
This commit replaces the manual blocking_notifier_chain_register() and
devm_add_action_or_reset() pattern with a single call to
devm_blocking_notifier_chain_register(), dropping the standalone
unregister callback.
> diff --git a/drivers/gpio/gpio-adp5585.c b/drivers/gpio/gpio-adp5585.c
> --- a/drivers/gpio/gpio-adp5585.c
> +++ b/drivers/gpio/gpio-adp5585.c
[ ... ]
> @@ -450,13 +440,9 @@ static int adp5585_gpio_probe(struct platform_device *pdev)
> girq->threaded = true;
>
> adp5585_gpio->nb.notifier_call = adp5585_gpio_key_event;
> - ret = blocking_notifier_chain_register(&adp5585->event_notifier,
> - &adp5585_gpio->nb);
> - if (ret)
> - return ret;
> -
> - ret = devm_add_action_or_reset(dev, adp5585_gpio_unreg_notifier,
> - adp5585_gpio);
> + ret = devm_blocking_notifier_chain_register(dev,
> + &adp5585->event_notifier,
> + &adp5585_gpio->nb);
[Severity: High]
This is a pre-existing issue, but does this devres registration order create
a use-after-free during device unbind?
Because the notifier is registered before the GPIO chip is added via
devm_gpiochip_add_data() later in adp5585_gpio_probe(), devres will process
the teardown in LIFO order. This means the GPIO chip and its IRQ domain are
removed and freed first.
If an interrupt fires after the GPIO chip is removed but before the notifier
is unregistered, the notifier callback adp5585_gpio_key_event() will attempt
to access the freed domain:
drivers/gpio/gpio-adp5585.c:adp5585_gpio_key_event() {
...
irq = irq_find_mapping(adp5585_gpio->gpio_chip.irq.domain, off);
if (!irq)
return NOTIFY_BAD;
...
}
Should the notifier registration be moved after devm_gpiochip_add_data() to
ensure a safe teardown sequence?
> if (ret)
> return ret;
> }
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260726101739.33170-1-farbere@amazon.com?part=5
next prev parent reply other threads:[~2026-07-26 10:27 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-26 10:17 [PATCH v4 00/13] notifier: add device-managed registration APIs and convert drivers Eliav Farber
2026-07-26 10:17 ` [PATCH v4 01/13] notifier: add device-managed registration APIs Eliav Farber
2026-07-26 10:17 ` [PATCH v4 02/13] pwm: iqs620a: use devm_blocking_notifier_chain_register() Eliav Farber
2026-07-26 10:17 ` [PATCH v4 03/13] iio: light: iqs621-als: " Eliav Farber
2026-07-26 10:17 ` [PATCH v4 04/13] iio: position: iqs624: " Eliav Farber
2026-07-26 10:17 ` [PATCH v4 05/13] gpio: adp5585: " Eliav Farber
2026-07-26 10:27 ` sashiko-bot [this message]
2026-07-26 10:17 ` [PATCH v4 06/13] platform/x86: bitland-mifs-wmi: " Eliav Farber
2026-07-26 10:27 ` sashiko-bot
2026-07-26 10:17 ` [PATCH v4 07/13] Input: adp5585: " Eliav Farber
2026-07-26 10:17 ` [PATCH v4 08/13] ACPI: APEI: GHES: remove unused ghes_{,un}register_vendor_record_notifier() Eliav Farber
2026-07-26 10:17 ` [PATCH v4 09/13] ACPI: APEI: GHES: use devm_blocking_notifier_chain_register() Eliav Farber
2026-07-26 10:17 ` [PATCH v4 10/13] platform/x86: uniwill-wmi: " Eliav Farber
2026-07-26 10:17 ` [PATCH v4 11/13] gpio: eic-sprd: use devm_atomic_notifier_chain_register() Eliav Farber
2026-07-26 10:28 ` sashiko-bot
2026-07-26 10:17 ` [PATCH v4 12/13] gpio: gpiolib-kunit: use devm_blocking_notifier_chain_register() Eliav Farber
2026-07-26 10:17 ` [PATCH v4 13/13] reboot: " Eliav Farber
2026-07-26 14:10 ` [PATCH v4 00/13] notifier: add device-managed registration APIs and convert drivers Borislav Petkov
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=20260726102753.B172C1F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=dmitry.torokhov@gmail.com \
--cc=farbere@amazon.com \
--cc=linux-input@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.