From: sashiko-bot@kernel.org
To: "Rob Clark" <robin.clark@oss.qualcomm.com>,
dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v3 6/6] drm/msm: Treat !mapped as an error
Date: Tue, 27 Oct 2026 23:17:57 +0000 [thread overview]
Message-ID: <sashiko-outbox-187203@kernel.org> (raw)
In-Reply-To: <20261027230452.130031-7-robin.clark@oss.qualcomm.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] drm/msm: __do_map() still returns 0 when sg_table maps nothing or short len
--
commit 363087af17cd51ea419c705b08215e2c785556f3
Author: Rob Clark <robin.clark@oss.qualcomm.com>
drm/msm: Treat !mapped as an error
This commit treats zero mapped bytes after an ops->map() call in __do_map()
as -ENOMEM so that mapping nothing is handled as an error rather than
silently ignored.
> diff --git a/drivers/gpu/drm/msm/msm_iommu.c b/drivers/gpu/drm/msm/msm_iommu.c
> index c2950d32c5075..255972323f9a9 100644
> --- a/drivers/gpu/drm/msm/msm_iommu.c
> +++ b/drivers/gpu/drm/msm/msm_iommu.c
> @@ -186,6 +186,10 @@ __do_map(unsigned long pgsize_bitmap, u64 iova, struct sg_table *sgt, size_t off
> size -= mapped;
> len -= mapped;
>
> + /* If nothing was mapped, consider it an ENOMEM. */
> + if (!ret && !mapped)
> + ret = -ENOMEM;
[Severity: Medium]
Can __do_map() in drivers/gpu/drm/msm/msm_iommu.c still silently return 0
without mapping anything (or after mapping fewer than len bytes) when called
via vm_map_op() -> msm_iommu_pagetable_map() or msm_iommu_map()?
The new !mapped check is placed inside the inner while (size) loop, which
only executes when size = sg_dma_len(sg) > 0 (and where ret == 0 with
mapped == 0 would previously have caused an infinite loop rather than
silently returning).
However, if sg_dma_len(sg) == 0 (for example, when an sg_table is not
DMA-mapped, or analogous to the sg->length == 0 case under
CONFIG_DMABUF_DEBUG before commit b6b3547f9503 ("drm/msm: Convert map helper
to use dma-address")), the outer loop in __do_map() skips the inner while
(size) loop altogether because 0 <= off is always true for unsigned size_t:
drivers/gpu/drm/msm/msm_iommu.c:__do_map() {
for_each_sgtable_dma_sg (sgt, sg, i) {
size_t size = sg_dma_len(sg);
phys_addr_t phys = sg_dma_address(sg);
if (!len)
break;
if (size <= off) {
off -= size;
continue;
}
...
while (size) {
...
}
}
return 0;
}
Similarly, if sgt->nents == 0 or the total DMA length across sgt is smaller
than off + len (which msm_iommu_map() checked via return (ret == len) ? 0 :
-EINVAL before commit efc83727eef1 ("drm/msm: Convert iommu map/unmap to
helpers")), for_each_sgtable_dma_sg() finishes with len > 0 and __do_map()
still returns 0 without unmapping addr - iova via __do_unmap() or marking
the VM unusable.
Should __do_map() also check if len != 0 after the for_each_sgtable_dma_sg()
loop and unmap any partial range before returning an error?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261027230452.130031-1-robin.clark@oss.qualcomm.com?part=6
prev parent reply other threads:[~2026-10-27 23:18 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-27 23:04 [PATCH v3 0/6] drm/msm: DMABUF_DEBUG fixes Rob Clark
2026-10-27 23:04 ` [PATCH v3 1/6] drm/msm: Cleanup if pages_to_sg() fails Rob Clark
2026-10-27 23:04 ` [PATCH v3 2/6] drm/msm/gem: dma_map/unmap_sgtable() Rob Clark
2026-10-27 23:24 ` sashiko-bot
2026-10-27 23:04 ` [PATCH v3 3/6] drm/msm: Extract out map/unmap helpers Rob Clark
2026-10-27 23:04 ` [PATCH v3 4/6] drm/msm: Convert iommu map/unmap to helpers Rob Clark
2026-10-27 23:18 ` sashiko-bot
2026-10-27 23:04 ` [PATCH v3 5/6] drm/msm: Convert map helper to use dma-address Rob Clark
2026-10-27 23:25 ` sashiko-bot
2026-10-28 1:14 ` Dmitry Baryshkov
2026-10-28 1:34 ` Rob Clark
2026-10-27 23:04 ` [PATCH v3 6/6] drm/msm: Treat !mapped as an error Rob Clark
2026-10-27 23:17 ` 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=sashiko-outbox-187203@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=robin.clark@oss.qualcomm.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.