From: sashiko-bot@kernel.org
To: "Arun Iyengar" <aiyengar1990@gmail.com>
Cc: dri-devel@lists.freedesktop.org, media-ci@linuxtv.org
Subject: Re: [PATCH v4 4/7] accel/rocket: Serialise core probe and removal
Date: Sun, 06 Dec 2026 07:42:47 +0000 [thread overview]
Message-ID: <sashiko-outbox-252256@kernel.org> (raw)
In-Reply-To: <20261206-rocket-fixes-v4-4-75a6279bce98@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] accel/rocket: devm_request_threaded_irq() outlives core slot
and rdev->cores
--
commit 54867f95a258b72cc2f95c965d1a7ae51bc6960f
Author: Arun Iyengar <aiyengar1990@gmail.com>
accel/rocket: Serialise core probe and removal
This commit serialises core probe, removal, and open under a mutex,
clears core slots on removal, and picks the first free slot on probe
and a bound core on open.
Link: https://lore.kernel.org/all/20260922080114.44662-5-royalnet026@gmail.com/ [1]
> diff --git a/drivers/accel/rocket/rocket_drv.c b/drivers/accel/rocket/rocket_drv.c
> index e45b3c22b31e6..ccaedb004d195 100644
> --- a/drivers/accel/rocket/rocket_drv.c
> +++ b/drivers/accel/rocket/rocket_drv.c
[ ... ]
> @@ -246,12 +271,16 @@ static int find_core_for_dev(struct device *dev);
> static void rocket_remove(struct platform_device *pdev)
> {
> struct device *dev = &pdev->dev;
> - int core = find_core_for_dev(dev);
> + int core;
> +
> + guard(mutex)(&rocket_cores_lock);
>
> + core = find_core_for_dev(dev);
> if (core < 0)
> return;
>
> rocket_core_fini(&rdev->cores[core]);
> + WRITE_ONCE(rdev->cores[core].dev, NULL);
> rdev->num_cores--;
>
> if (rdev->num_cores == 0) {
[Severity: Medium]
Can the shared IRQ handler registered by rocket_job_init() run after
core->dev is cleared or rdev->cores is freed?
rocket_job_init() registers its IRQF_SHARED handler via
devm_request_threaded_irq() with core (&rdev->cores[core]) as dev_id,
binding the IRQ lifetime to &pdev->dev.
Neither rocket_core_fini() nor rocket_job_fini() frees the IRQ, so
free_irq() only runs later in device_unbind_cleanup() ->
devres_release_all() after rocket_remove() (or a failed rocket_probe())
returns and releases rocket_cores_lock:
CPU0 CPU1
rocket_remove()
rocket_core_fini(core)
WRITE_ONCE(core->dev, NULL)
/* unlocks rocket_cores_lock */
rocket_probe()
/* reuses slot for new core */
<shared IRQ>
rocket_job_irq_handler(..., core)
<-- races with reused slot
device_unbind_cleanup()
devres_release_all()
free_irq()
In that window, rocket_job_handle_irq() also dereferences a NULL
core->dev in pm_runtime_mark_last_busy(). On last-core removal, freeing
rdev->cores via devres_release_group() before free_irq() runs causes a
use-after-free on a shared IRQ or in __free_irq() under CONFIG_DEBUG_SHIRQ.
Freeing the IRQ in rocket_job_fini() with devm_free_irq() (or switching
to request_threaded_irq() and free_irq()) would ensure the handler cannot
outlive the core slot.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261206-rocket-fixes-v4-0-75a6279bce98@gmail.com?part=4
next prev parent reply other threads:[~2026-12-06 7:43 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-06 7:17 [PATCH v4 0/7] accel/rocket: Fix teardown with a job on the NPU Arun Iyengar
2026-12-06 7:17 ` Arun Iyengar via B4 Relay
2026-12-06 7:17 ` Arun Iyengar via B4 Relay
2026-12-06 7:17 ` [PATCH v4 1/7] accel/rocket: Wait for in-flight jobs before releasing the file's BOs Arun Iyengar
2026-12-06 7:17 ` Arun Iyengar via B4 Relay
2026-12-06 7:17 ` Arun Iyengar via B4 Relay
2026-12-06 7:17 ` [PATCH v4 2/7] accel/rocket: Reset the core before detaching its IOMMU Arun Iyengar
2026-12-06 7:17 ` Arun Iyengar via B4 Relay
2026-12-06 7:17 ` Arun Iyengar via B4 Relay
2026-12-06 7:17 ` [PATCH v4 3/7] accel/rocket: Stop the scheduler before releasing the IOMMU group Arun Iyengar
2026-12-06 7:17 ` Arun Iyengar via B4 Relay
2026-12-06 7:17 ` Arun Iyengar via B4 Relay
2026-12-06 7:17 ` [PATCH v4 4/7] accel/rocket: Serialise core probe and removal Arun Iyengar
2026-12-06 7:17 ` Arun Iyengar via B4 Relay
2026-12-06 7:17 ` Arun Iyengar via B4 Relay
2026-12-06 7:42 ` sashiko-bot [this message]
2026-12-06 7:17 ` [PATCH v4 5/7] accel/rocket: Reset the core at unbind Arun Iyengar
2026-12-06 7:17 ` Arun Iyengar via B4 Relay
2026-12-06 7:17 ` Arun Iyengar via B4 Relay
2026-12-06 7:41 ` sashiko-bot
2026-12-06 7:17 ` [PATCH v4 6/7] accel/rocket: Free the jobs left at scheduler teardown Arun Iyengar
2026-12-06 7:17 ` Arun Iyengar via B4 Relay
2026-12-06 7:17 ` Arun Iyengar via B4 Relay
2026-12-06 7:17 ` [PATCH v4 7/7] accel/rocket: Move open files off a core at unbind Arun Iyengar
2026-12-06 7:17 ` Arun Iyengar via B4 Relay
2026-12-06 7:17 ` Arun Iyengar via B4 Relay
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-252256@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=aiyengar1990@gmail.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=media-ci@linuxtv.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.