From: sashiko-bot@kernel.org
To: "Guangshuo Li" <lgs201920130244@gmail.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH] accel/ivpu: fix usage_count leak when autosuspend_delay is negative
Date: Fri, 07 Aug 2026 15:20:21 +0000 [thread overview]
Message-ID: <20260807152022.291B61F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260807145416.2518999-1-lgs201920130244@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] Background work items scheduled by IRQ handlers are not flushed or canceled on the probe error path, leading to a Use-After-Free when devres frees the device.
--
--- Patch [1]: [PATCH] accel/ivpu: fix usage_count leak when autosuspend_delay is negative ---
commit db53366ef5dbe7e33ab10b0d9f2d73d71bbd452a
Author: Guangshuo Li <lgs201920130244@gmail.com>
accel/ivpu: fix usage_count leak when autosuspend_delay is negative
ivpu_pm_init() calls pm_runtime_use_autosuspend(), but the autosuspend
setting is not disabled when the device is removed or when initialization
fails. This patch adds pm_runtime_dont_use_autosuspend() to ivpu_pm_disable()
and the ivpu_dev_init() error path to prevent a usage_count leak.
> diff --git a/drivers/accel/ivpu/ivpu_drv.c b/drivers/accel/ivpu/ivpu_drv.c
> index 95120957f42a5..f8460aca189cd 100644
> --- a/drivers/accel/ivpu/ivpu_drv.c
> +++ b/drivers/accel/ivpu/ivpu_drv.c
[ ... ]
> @@ -776,13 +776,15 @@ static int ivpu_dev_init(struct ivpu_device *vdev)
>
> ret = ivpu_boot(vdev);
> if (ret)
> - goto err_ipc_fini;
> + goto err_pm_fini;
>
> ivpu_job_done_consumer_init(vdev);
> ivpu_pm_enable(vdev);
>
> return 0;
>
> +err_pm_fini:
> + pm_runtime_dont_use_autosuspend(vdev->drm.dev);
[Severity: High]
This is a pre-existing issue, but since we are modifying the error paths
here, I noticed that background work items scheduled by IRQ handlers might
not be flushed or canceled on the probe error path.
If a hardware interrupt occurs during ivpu_boot() after enable_irq() is called,
the handler may queue irq_dct_work or context_abort_work. If a subsequent
initialization step like ivpu_pm_dct_init() fails, the error path disables
interrupts but skips flushing the queued works:
ivpu_boot() {
...
enable_irq(vdev->irq);
...
ret = ivpu_pm_dct_init(vdev);
if (ret)
goto err_disable_ipc;
...
err_disable_ipc:
ivpu_ipc_disable(vdev);
ivpu_hw_irq_disable(vdev);
disable_irq(vdev->irq);
...
}
The error is then returned to ivpu_dev_init(), which jumps to err_pm_fini
where this new cleanup code is placed.
Could this lead to a memory corruption scenario? Without cancel_work_sync()
or flush_work() to halt pending tasks, devres might free the ivpu_device
structure when probe fails. Any pending work items might later execute and
dereference the freed pointer.
> err_ipc_fini:
> ivpu_ipc_fini(vdev);
> err_fw_fini:
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260807145416.2518999-1-lgs201920130244@gmail.com?part=1
prev parent reply other threads:[~2026-08-07 15:20 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-07 14:54 [PATCH] accel/ivpu: fix usage_count leak when autosuspend_delay is negative Guangshuo Li
2026-08-07 15:20 ` sashiko-bot [this message]
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=20260807152022.291B61F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=lgs201920130244@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.