From: sashiko-bot@kernel.org
To: "Alexandru Dadu" <alexandru.dadu@imgtec.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH 4/6] drm/imagination: Release firmware after init
Date: Wed, 25 Nov 2026 11:59:15 +0000 [thread overview]
Message-ID: <sashiko-outbox-233307@kernel.org> (raw)
In-Reply-To: <20261125-b4-commonize-fw-segment-loading-v1-4-69657fa52ac3@imgtec.com>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] drm/imagination: memory leak of fw_dev.metadata on GPU init
error paths
--
commit 8d2db63e357e744b233475780670c4fc83790aca
Author: Matt Coster <opensource@mtcoster.net>
drm/imagination: Release firmware after init
This commit stops storing struct firmware in pvr_fw_device and instead
passes it through the initialization functions and releases it at the end
of pvr_device_gpu_init().
> diff --git a/drivers/gpu/drm/imagination/pvr_device.c b/drivers/gpu/drm/imagination/pvr_device.c
> index 0c4832d2cce1b..210eeb91f4ecf 100644
> --- a/drivers/gpu/drm/imagination/pvr_device.c
> +++ b/drivers/gpu/drm/imagination/pvr_device.c
[ ... ]
> @@ -701,40 +691,52 @@ pvr_device_info_validate(struct pvr_device *pvr_dev)
> static int
> pvr_device_gpu_init(struct pvr_device *pvr_dev)
> {
> + const struct firmware *firmware;
> int err;
>
> err = pvr_load_gpu_id(pvr_dev);
> if (err)
> return err;
>
> - err = pvr_request_firmware(pvr_dev);
> - if (err)
> - return err;
> + firmware = pvr_request_firmware(pvr_dev);
> + if (IS_ERR(firmware))
> + return PTR_ERR(firmware);
>
> - err = pvr_fw_load_metadata_and_device_info(pvr_dev);
> + err = pvr_fw_load_metadata_and_device_info(pvr_dev, firmware);
> if (err)
> - return err;
> + goto out_release_firmware;
>
> - if (PVR_HAS_FEATURE(pvr_dev, meta))
> + if (PVR_HAS_FEATURE(pvr_dev, meta)) {
> pvr_dev->fw_dev.processor_type = PVR_FW_PROCESSOR_TYPE_META;
> - else if (PVR_HAS_FEATURE(pvr_dev, mips))
> + } else if (PVR_HAS_FEATURE(pvr_dev, mips)) {
> pvr_dev->fw_dev.processor_type = PVR_FW_PROCESSOR_TYPE_MIPS;
> - else if (PVR_HAS_FEATURE(pvr_dev, riscv_fw_processor))
> + } else if (PVR_HAS_FEATURE(pvr_dev, riscv_fw_processor)) {
> pvr_dev->fw_dev.processor_type = PVR_FW_PROCESSOR_TYPE_RISCV;
> - else
> - return -EINVAL;
> + } else {
> + err = -EINVAL;
> + goto out_release_firmware;
> + }
>
> err = pvr_device_info_validate(pvr_dev);
> if (err)
> - return err;
> + goto out_release_firmware;
>
> pvr_stream_create_musthave_masks(pvr_dev);
>
> err = pvr_set_dma_info(pvr_dev);
> if (err)
> - return err;
> + goto out_release_firmware;
>
> - return pvr_fw_init(pvr_dev);
> + err = pvr_fw_init(pvr_dev, firmware);
> + if (err)
> + goto out_release_firmware;
> +
> + err = 0;
> +
> +out_release_firmware:
> + release_firmware(firmware);
> +
> + return err;
> }
[Severity: Medium]
Do the error paths here leak pvr_dev->fw_dev.metadata?
pvr_fw_load_metadata() allocates metadata with kzalloc_flex() and
pvr_fw_load_metadata_and_device_info() assigns it to
pvr_dev->fw_dev.metadata before calling pvr_fw_get_device_info(). If
pvr_fw_get_device_info() or any later step in pvr_device_gpu_init()
such as pvr_fw_init() fails, pvr_device_init() jumps past
pvr_device_gpu_fini(), so pvr_fw_free_metadata_and_device_info() is
never called.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261125-b4-commonize-fw-segment-loading-v1-0-69657fa52ac3@imgtec.com?part=4
next prev parent reply other threads:[~2026-11-25 11:59 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 [this message]
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
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-233307@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.