From: sashiko-bot@kernel.org
To: "Alexandru Dadu" <alexandru.dadu@imgtec.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH 5/6] drm/imagination: Generalize FW segment loading
Date: Wed, 25 Nov 2026 12:00:13 +0000 [thread overview]
Message-ID: <sashiko-outbox-233318@kernel.org> (raw)
In-Reply-To: <20261125-b4-commonize-fw-segment-loading-v1-5-69657fa52ac3@imgtec.com>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] drm/imagination: missing pvr_fw_object_vunmap() on
pvr_fw_process() error path
--
commit 77938768831abdc044ee8cfa1b2e3bb5e025c962
Author: Matt Coster <opensource@mtcoster.net>
drm/imagination: Generalize FW segment loading
This commit replaces the per-segment firmware loading code and fields in
struct pvr_fw_mem with a segment descriptor table and an array of struct
pvr_fw_segment entries.
> diff --git a/drivers/gpu/drm/imagination/pvr_fw.c b/drivers/gpu/drm/imagination/pvr_fw.c
> index 4e082f83cff02..fbd46231f5803 100644
> --- a/drivers/gpu/drm/imagination/pvr_fw.c
> +++ b/drivers/gpu/drm/imagination/pvr_fw.c
[ ... ]
> @@ -462,6 +426,76 @@ pvr_fw_destroy_structures(struct pvr_device *pvr_dev)
[ ... ]
> +static void
> +pvr_fw_destroy_segments(struct pvr_fw_segment segments[static PVR_FW_SEGMENT_COUNT])
> +{
> + for (int i = PVR_FW_SEGMENT_COUNT - 1; i >= 0; i--) {
> + struct pvr_fw_segment *segment = &segments[i];
> +
> + if (segment->obj)
> + pvr_fw_object_destroy(segment->obj);
> + segment->obj = NULL;
> +
> + kfree(segment->host_copy);
> + segment->host_copy = NULL;
> + }
> +}
[ ... ]
> @@ -492,142 +526,58 @@ pvr_fw_process(struct pvr_device *pvr_dev, const struct firmware *firmware)
> return -EINVAL;
>
> /* Allocate and map memory for firmware sections. */
> + for (int seg = 0; seg < PVR_FW_SEGMENT_COUNT; seg++) {
> + const struct pvr_fw_segment_desc *desc = &pvr_fw_segment_descs[seg];
> + struct pvr_fw_segment *segment = &fw_mem->segments[seg];
> + void *host_ptr;
> +
> + if (!segment->size) {
> + if (desc->required) {
> + drm_err(drm_dev, "Required FW segment '%s' is empty\n", desc->name);
> + err = -EINVAL;
> + goto err_out;
> + }
>
> + continue;
> + }
>
> + segment->host_copy = kzalloc(segment->size, GFP_KERNEL);
> + if (!segment->host_copy) {
> + err = -ENOMEM;
> + goto err_out;
> + }
>
> + host_ptr = desc->create_and_map(pvr_dev, segment, private_data->base_addr);
> + if (IS_ERR(host_ptr)) {
> + drm_err(drm_dev, "Failed to allocate FW memory for segment '%s'\n",
> + desc->name);
> + err = PTR_ERR(host_ptr);
> + goto err_out;
> + }
>
> + host_ptrs[seg] = host_ptr;
> }
>
> + err = pvr_dev->fw_dev.defs->fw_process(pvr_dev, firmware, fw_mem->segments);
> if (err)
> + goto err_out;
> +
> + for (int seg = 0; seg < PVR_FW_SEGMENT_COUNT; seg++) {
> + const struct pvr_fw_segment *segment = &fw_mem->segments[seg];
> +
> + if (!segment->obj)
> + continue;
> +
> + memcpy(host_ptrs[seg], segment->host_copy, segment->size);
> +
> + host_ptrs[seg] = NULL;
> + pvr_fw_object_vunmap(segment->obj);
> }
>
> return 0;
>
> +err_out:
> + pvr_fw_destroy_segments(fw_mem->segments);
>
> return err;
> }
[Severity: Medium]
Does the err_out path in pvr_fw_process() miss calling
pvr_fw_object_vunmap() on segments that were already mapped by
desc->create_and_map()?
If a later segment allocation or defs->fw_process() fails,
pvr_fw_destroy_segments() destroys each segment->obj while its CPU mapping
in host_ptrs[seg] is still active. Unlike the pre-patch cleanup path,
which called pvr_fw_object_vunmap() before pvr_fw_object_destroy(),
destroying the still-mapped GEM shmem object triggers drm_WARN_ON() in
drm_gem_shmem_release() and leaks the vmap mapping and pinned backing
pages.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261125-b4-commonize-fw-segment-loading-v1-0-69657fa52ac3@imgtec.com?part=5
next prev parent reply other threads:[~2026-11-25 12:00 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-25 11:48 [PATCH 0/6] drm/imagination: Commonize firmware segment loading Alexandru Dadu
2026-11-25 11:48 ` Alexandru Dadu
2026-11-25 11:48 ` [PATCH 1/6] drm/imagination: Remove get_fw_obj_gpu_addr() Alexandru Dadu
2026-11-25 11:48 ` Alexandru Dadu
2026-11-25 11:48 ` [PATCH 2/6] drm/imagination: Fix size of FW header members Alexandru Dadu
2026-11-25 11:48 ` Alexandru Dadu
2026-11-25 11:48 ` [PATCH 3/6] drm/imagination: Save metadata from firmware Alexandru Dadu
2026-11-25 11:48 ` Alexandru Dadu
2026-11-25 12:01 ` sashiko-bot
2026-11-26 5:12 ` kernel test robot
2026-11-26 5:12 ` kernel test robot
2026-11-27 19:36 ` kernel test robot
2026-11-27 19:36 ` kernel test robot
2026-11-25 11:48 ` [PATCH 4/6] drm/imagination: Release firmware after init Alexandru Dadu
2026-11-25 11:48 ` Alexandru Dadu
2026-11-25 11:59 ` sashiko-bot
2026-11-25 11:48 ` [PATCH 5/6] drm/imagination: Generalize FW segment loading Alexandru Dadu
2026-11-25 11:48 ` Alexandru Dadu
2026-11-25 12:00 ` sashiko-bot [this message]
2026-11-25 11:48 ` [PATCH 6/6] drm/imagination: Avoid loop in configure_seg_mmu() Alexandru Dadu
2026-11-25 11:48 ` Alexandru Dadu
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-233318@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=alexandru.dadu@imgtec.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 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.