From: sashiko-bot@kernel.org
To: "Michail Tatas" <michail.tatas@gmail.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH] drm/amdgpu: unmap GART dma pages before free
Date: Tue, 22 Sep 2026 15:46:05 +0000 [thread overview]
Message-ID: <20260922154606.2C2721F000FF@smtp.kernel.org> (raw)
In-Reply-To: <arKhDFCSoPDNYaxX@michalis-linux>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] drm/amdgpu: NULL pointer dereference in amdgpu_gart_table_ram_alloc error path
--
commit cffcb1919743d55f9dc644f758abf99d4187be7c
Author: Michail Tatas <michail.tatas@gmail.com>
drm/amdgpu: unmap GART dma pages before free
This commit unmaps the GART dma pages before freeing them to avoid leaving
the device writing to freed memory.
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c
> index c4c21dbbbdbf8..780fb01530e69 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c
[ ... ]
> @@ -209,6 +209,8 @@ int amdgpu_gart_table_ram_alloc(struct amdgpu_device *adev)
> error_resv:
> amdgpu_bo_unreserve(bo);
> error:
> + dma_unmap_page(&adev->pdev->dev, sg_dma_address(sg->sgl), adev->gart.table_size,
> + DMA_BIDIRECTIONAL);
[Severity: High]
Can this cause a NULL pointer dereference during memory pressure?
If memory allocation fails earlier in amdgpu_gart_table_ram_alloc(),
sg is set to NULL and execution jumps to the error label:
sg = kmalloc_obj(*sg);
if (!sg) {
ret = -ENOMEM;
goto error;
}
The new dma_unmap_page() call unconditionally accesses sg->sgl at the error
label. If the execution arrived here due to the allocation failure above,
dereferencing sg->sgl will crash.
Additionally, if sg_alloc_table() fails, sg is allocated but sg->sgl may be
uninitialized when accessed here.
> amdgpu_bo_unref(&bo);
> if (sg) {
> sg_free_table(sg);
--
Sashiko AI review · https://sashiko.dev/#/patchset/arKhDFCSoPDNYaxX@michalis-linux?part=1
prev parent reply other threads:[~2026-09-22 15:46 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-22 15:38 [PATCH] drm/amdgpu: unmap GART dma pages before free Michail Tatas
2026-09-22 15:46 ` 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=20260922154606.2C2721F000FF@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=michail.tatas@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox