dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Thadeu Lima de Souza Cascardo" <cascardo@igalia.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH] drm/amdgpu: initialize irq.lock spinlock earlier
Date: Mon, 08 Jun 2026 19:39:38 +0000	[thread overview]
Message-ID: <20260608193938.CE7AC1F00893@smtp.kernel.org> (raw)
In-Reply-To: <20260608-amdgpu-mutex-fix-2-v1-1-1d850180ed19@igalia.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] The IH work queues (ih1_work, ih2_work, ih_soft_work) are not cancelled before freeing the IH ring buffers during hardware teardown, leading to a potential use-after-free or NULL pointer dereference.
--

commit d96f9c222586fdd4fb9ac2385c6edc335ba11a51
Author: Thadeu Lima de Souza Cascardo <cascardo@igalia.com>

drm/amdgpu: initialize irq.lock spinlock earlier

If there is an early failure during amdgpu probe, it will end up calling
amdgpu_irq_disable_all, which takes irq.lock spinlock without it being
initialized. Initializing irq.lock earlier at amdgpu_device_init fixes
the issue.

> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c
> index 82bc6d657e5a0..836ba07713649 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c
> @@ -309,8 +309,6 @@ int amdgpu_irq_init(struct amdgpu_device *adev)
>  	unsigned int irq, flags;
>  	int r;
>  
> -	spin_lock_init(&adev->irq.lock);
> -

[Severity: High]
This isn't a bug introduced by this patch, but looking at the driver
teardown, are the IH work queues ever cancelled?

In amdgpu_irq_init(), ih1_work, ih2_work, and ih_soft_work are initialized
and can be scheduled by the interrupt handler. However, during teardown:

drivers/gpu/drm/amd/amdgpu/amdgpu_irq.c:amdgpu_irq_fini_hw() {
	if (adev->irq.installed) {
		free_irq(adev->irq.irq, adev_to_drm(adev));
		adev->irq.installed = false;
...
	amdgpu_ih_ring_fini(adev, &adev->irq.ih_soft);
	amdgpu_ih_ring_fini(adev, &adev->irq.ih);
	amdgpu_ih_ring_fini(adev, &adev->irq.ih1);
	amdgpu_ih_ring_fini(adev, &adev->irq.ih2);
}

The driver frees the IRQ and the IH ring buffers, but does not explicitly
cancel the pending work items using cancel_work_sync().

If a scheduled work item executes concurrently with or after teardown, could
it dereference the freed adev or ih->ring pointers, leading to a
use-after-free or NULL pointer dereference?

Should the work items be cancelled synchronously before the ring buffers are
freed?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260608-amdgpu-mutex-fix-2-v1-1-1d850180ed19@igalia.com?part=1

  reply	other threads:[~2026-06-08 19:39 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-08 19:22 [PATCH] drm/amdgpu: initialize irq.lock spinlock earlier Thadeu Lima de Souza Cascardo
2026-06-08 19:39 ` sashiko-bot [this message]
2026-06-09  8:07 ` Tvrtko Ursulin
2026-06-15 15:09   ` Alex Deucher

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=20260608193938.CE7AC1F00893@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=cascardo@igalia.com \
    --cc=dri-devel@lists.freedesktop.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