From: sashiko-bot@kernel.org
To: "Krzysztof Karas" <krzysztof.karas@intel.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v3 5/5] drm/i915/gem: Remove iterator and use while loop
Date: Mon, 13 Jul 2026 10:09:27 +0000 [thread overview]
Message-ID: <20260713100928.0202E1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260713095812.1014365-6-krzysztof.karas@intel.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] Pinned folios are permanently leaked in the error path if an allocation fails before the scatterlist pointer `sg` is advanced past the first entry.
--
--- Patch [5]: [PATCH v3 5/5] drm/i915/gem: Remove iterator and use while loop ---
commit f3eba03d9fc5ce905a11cce1578d72ea21a144f1
Author: Krzysztof Karas <krzysztof.karas@intel.com>
drm/i915/gem: Remove iterator and use while loop
This commit changes the main "for" loop into a "while" loop to get rid of
the obscure iterator "i" and use a more descriptive name to indicate how
many pages were already covered.
> diff --git a/drivers/gpu/drm/i915/gem/i915_gem_shmem.c b/drivers/gpu/drm/i915/gem/i915_gem_shmem.c
> index 7c8de8fe0a225..66d0f8f6ffccb 100644
> --- a/drivers/gpu/drm/i915/gem/i915_gem_shmem.c
> +++ b/drivers/gpu/drm/i915/gem/i915_gem_shmem.c
[ ... ]
> @@ -212,7 +211,7 @@ int shmem_sg_alloc_table(struct drm_i915_private *i915, struct sg_table *st,
> }
>
> next_pfn = folio_pfn(folio) + folio_page_index + nr_pages;
> - i += nr_pages - 1;
> + pages_done += nr_pages;
>
> /* Check that the i965g/gm workaround works. */
> GEM_BUG_ON(gfp & __GFP_DMA32 && next_pfn >= 0x00100000UL);
[Severity: High]
This isn't a bug introduced by this patch, but looking at the error handling
in shmem_sg_alloc_table() in drivers/gpu/drm/i915/gem/i915_gem_shmem.c (around
line 228), is it possible to leak pinned folios?
If an allocation fails after successfully allocating the first folio(s) into
the first scatterlist entry, st->nents will be 1 but sg will still equal
st->sgl. The error path jumps to err_sg:
err_sg:
sg_mark_end(sg);
if (sg != st->sgl) {
shmem_sg_free_table(st, mapping, false, false);
} else {
mapping_clear_unevictable(mapping);
sg_free_table(st);
}
Since sg == st->sgl, this takes the else branch and bypasses
shmem_sg_free_table(), leaving the folios in the first scatterlist entry
pinned. Would checking if (st->nents > 0) be more appropriate here?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260713095812.1014365-1-krzysztof.karas@intel.com?part=5
next prev parent reply other threads:[~2026-07-13 10:09 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-13 9:58 [PATCH v3 0/5] drivers: Improve memory management for large object allocations when i915/shmem is used with iommu Krzysztof Karas
2026-07-13 9:58 ` [PATCH v3 1/5] drm/i915/gem: Count mapped pages in a folio Krzysztof Karas
2026-07-13 9:58 ` [PATCH v3 2/5] iommu/dma: Catch scatterlist length overflows Krzysztof Karas
2026-07-13 10:13 ` sashiko-bot
2026-07-13 9:58 ` [PATCH v3 3/5] drm/i915/gem: Pull out size validation into a separate function Krzysztof Karas
2026-07-13 9:58 ` [PATCH v3 4/5] drm/i915/gem: Read and shrink memory in " Krzysztof Karas
2026-07-13 10:10 ` sashiko-bot
2026-07-13 9:58 ` [PATCH v3 5/5] drm/i915/gem: Remove iterator and use while loop Krzysztof Karas
2026-07-13 10:09 ` sashiko-bot [this message]
2026-07-13 11:01 ` ✓ i915.CI.BAT: success for drivers: Improve memory management for large object allocations when i915/shmem is used with iommu Patchwork
2026-07-13 14:14 ` ✗ i915.CI.Full: failure " Patchwork
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=20260713100928.0202E1F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=krzysztof.karas@intel.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.