From: sashiko-bot@kernel.org
To: "Honglei Huang" <honglei1.huang@amd.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v5 2/5] drm/gpusvm: embed struct drm_device into drm_gpusvm_pages
Date: Sat, 27 Jun 2026 04:07:27 +0000 [thread overview]
Message-ID: <20260627040727.B71EE1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260627035418.3796481-2-honglei1.huang@amd.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] Leak of device page DMA mappings in `drm_gpusvm_get_pages()` error path due to deferred assignment of `dpagemap`.
--
commit dfe7715229bc403af2e0a2fb749a3ef0875d2fdf
Author: Honglei Huang <honghuan@amd.com>
Subject: drm/gpusvm: embed struct drm_device into drm_gpusvm_pages
This patch embeds a drm_device pointer directly into drm_gpusvm_pages to
make the physical pages and their DMA view inherently bound to a specific
drm_device. It updates the DMA mapping functions to route all DMA through
svm_pages->drm instead of gpusvm->drm.
> diff --git a/drivers/gpu/drm/drm_gpusvm.c b/drivers/gpu/drm/drm_gpusvm.c
> index df900553f21a4..155e3c2e703d9 100644
> --- a/drivers/gpu/drm/drm_gpusvm.c
> +++ b/drivers/gpu/drm/drm_gpusvm.c
[ ... ]
> @@ -1532,10 +1541,10 @@ int drm_gpusvm_get_pages(struct drm_gpusvm *gpusvm,
> }
> svm_pages->dma_addr[j] =
> dpagemap->ops->device_map(dpagemap,
> - gpusvm->drm->dev,
> + svm_pages->drm->dev,
> page, order,
> dma_dir);
> - if (dma_mapping_error(gpusvm->drm->dev,
> + if (dma_mapping_error(svm_pages->drm->dev,
> svm_pages->dma_addr[j].addr)) {
> err = -EFAULT;
> goto err_unmap;
[Severity: High]
This is a pre-existing issue, but does this error path permanently leak
device page DMA mappings?
If dma_mapping_error() fails here (or if dma_iova_sync() fails later), the
code jumps to the err_unmap label which calls __drm_gpusvm_unmap_pages():
err_unmap:
svm_pages->flags.has_dma_mapping = true;
__drm_gpusvm_unmap_pages(gpusvm, svm_pages, num_dma_mapped);
However, svm_pages->dpagemap isn't assigned until the end of
drm_gpusvm_get_pages() on complete success.
In __drm_gpusvm_unmap_pages(), it checks:
struct drm_pagemap *dpagemap = svm_pages->dpagemap;
...
else if (dpagemap && dpagemap->ops->device_unmap)
Since svm_pages->dpagemap is still NULL during the error path, the device
unmap operations will be skipped, leaving the successfully mapped device pages
in this batch leaked.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260627035418.3796481-1-honglei1.huang@amd.com?part=2
next prev parent reply other threads:[~2026-06-27 4:07 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-27 3:54 [PATCH v5 1/5] drm/gpusvm: split MM state flags out of drm_gpusvm_pages_flags Honglei Huang
2026-06-27 3:54 ` [PATCH v5 2/5] drm/gpusvm: embed struct drm_device into drm_gpusvm_pages Honglei Huang
2026-06-27 4:07 ` sashiko-bot [this message]
2026-06-27 3:54 ` [PATCH v5 3/5] drm/xe: have xe_svm_range embed one drm_gpusvm_pages Honglei Huang
2026-06-27 4:16 ` sashiko-bot
2026-06-27 3:54 ` [PATCH v5 4/5] drm/gpusvm: move struct drm_gpusvm_pages out of struct drm_gpusvm_range Honglei Huang
2026-06-27 4:33 ` sashiko-bot
2026-06-27 3:54 ` [PATCH v5 5/5] drm/gpusvm: let the drm_gpusvm core context purely MM level Honglei Huang
2026-06-27 3:54 ` [PATCH v5 0/5] drm/gpusvm: split MM and device state across gpusvm/range/pages Honglei Huang
2026-06-27 4:10 ` [PATCH v5 1/5] drm/gpusvm: split MM state flags out of drm_gpusvm_pages_flags sashiko-bot
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=20260627040727.B71EE1F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=honglei1.huang@amd.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.