From: sashiko-bot@kernel.org
To: "Mukesh Ojha" <mukesh.ojha@oss.qualcomm.com>
Cc: dri-devel@lists.freedesktop.org, media-ci@linuxtv.org
Subject: Re: [PATCH 3/8] media: iris: migrate firmware loading to qcom_mdt_pas_load() and qcom_pas_prepare_and_auth_reset()
Date: Sat, 26 Sep 2026 15:59:35 +0000 [thread overview]
Message-ID: <20260926155935.D7FDD1F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260925155737.4161358-4-mukesh.ojha@oss.qualcomm.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] firmware: qcom: pas: missing qcom_pas_metadata_release() leaks TZ/DMA memory
- [Medium] devres: memory leak due to repeated devm_qcom_pas_context_alloc() on fw reload
--
commit bb3acb8beaa539b1cfa0975914c1f8fd75747e36
Author: Mukesh Ojha <mukesh.ojha@oss.qualcomm.com>
media: iris: migrate firmware loading to qcom_mdt_pas_load() and qcom_pas_prepare_and_auth_reset()
iris_load_fw_to_memory() calls qcom_mdt_load() which bundles metadata
init, memory setup, and segment loading with no PAS context, and
iris_fw_load() calls qcom_pas_auth_and_reset() which skips the shmbridge
prepare step required before TrustZone authentication.
> diff --git a/drivers/media/platform/qcom/iris/iris_firmware.c b/drivers/media/platform/qcom/iris/iris_firmware.c
> index 21cdf1c398357..e73a5dd98b88c 100644
> --- a/drivers/media/platform/qcom/iris/iris_firmware.c
> +++ b/drivers/media/platform/qcom/iris/iris_firmware.c
[ ... ]
> @@ -134,21 +131,20 @@ static int iris_load_fw_to_memory(struct iris_core *core)
> core->iris_firmware_data = core->iris_firmware_desc->firmware_data;
>
> fw_size = qcom_mdt_get_size(firmware);
> - if (fw_size < 0 || res_size < (size_t)fw_size) {
> + if (fw_size < 0 || resource_size(&res) < (size_t)fw_size) {
> ret = -EINVAL;
> goto err_release_fw;
> }
>
> - mem_virt = memremap(mem_phys, res_size, MEMREMAP_WC);
> - if (!mem_virt) {
> - ret = -ENOMEM;
> + core->pas_ctx = devm_qcom_pas_context_alloc(dev, IRIS_PAS_ID, mem_phys,
> + resource_size(&res));
[Severity: Medium]
Will this leak device-managed memory when firmware is reloaded?
If the hardware system error recovery path is triggered (for example,
iris_sys_error_handler() calls iris_core_deinit() followed by
iris_core_init() and iris_fw_load()), devm_qcom_pas_context_alloc() is called
again unconditionally. This overwrites core->pas_ctx without freeing the old
devres allocation.
> + if (IS_ERR(core->pas_ctx)) {
> + ret = PTR_ERR(core->pas_ctx);
> + core->pas_ctx = NULL;
> goto err_release_fw;
> }
>
> - ret = qcom_mdt_load(dev, firmware, fw_name,
> - IRIS_PAS_ID, mem_virt, mem_phys, res_size, NULL);
> -
> - memunmap(mem_virt);
> + ret = qcom_mdt_pas_load(core->pas_ctx, firmware, fw_name, NULL);
[Severity: High]
Does this sequence leak DMA or TrustZone memory buffers allocated for firmware
metadata?
When qcom_mdt_pas_load() is called, the underlying PAS subsystem allocates a
DMA buffer for the metadata and stores it in the PAS context. The PAS API
contract dictates that callers must subsequently call
qcom_pas_metadata_release(core->pas_ctx) to free this memory.
Looking at iris_fw_load(), this step appears to be completely omitted on both
success and error paths before the function returns. Because the DMA
allocation is tied to the SCM device (not devres-managed for the iris
driver), repeated firmware loads due to probe/unbind cycles or hardware
errors could permanently exhaust restricted DMA or secure memory pools.
> err_release_fw:
> release_firmware(firmware);
>
> @@ -166,7 +162,7 @@ int iris_fw_load(struct iris_core *core)
> return ret;
> }
>
> - ret = qcom_pas_auth_and_reset(IRIS_PAS_ID);
> + ret = qcom_pas_prepare_and_auth_reset(core->pas_ctx);
> if (ret) {
> dev_err(core->dev, "auth and reset failed: %d\n", ret);
> return ret;
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260925155737.4161358-1-mukesh.ojha@oss.qualcomm.com?part=3
next prev parent reply other threads:[~2026-09-26 15:59 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-25 15:57 [PATCH 0/8] Migrate PAS clients to qcom_mdt_pas_load() and qcom_pas_prepare_and_auth_reset() Mukesh Ojha
2026-09-25 15:57 ` [PATCH 1/8] remoteproc: qcom_wcnss: migrate " Mukesh Ojha
2026-09-26 15:59 ` sashiko-bot
2026-09-25 15:57 ` [PATCH 2/8] drm/msm/adreno: migrate zap shader loading " Mukesh Ojha
2026-09-26 15:59 ` sashiko-bot
2026-09-25 15:57 ` [PATCH 3/8] media: iris: migrate firmware " Mukesh Ojha
2026-09-26 15:59 ` sashiko-bot [this message]
2026-09-25 15:57 ` [PATCH 4/8] media: venus: " Mukesh Ojha
2026-09-26 15:59 ` sashiko-bot
2026-09-25 15:57 ` [PATCH 5/8] net: ipa: " Mukesh Ojha
2026-09-26 15:59 ` sashiko-bot
2026-09-25 15:57 ` [PATCH 6/8] wifi: ath12k: " Mukesh Ojha
2026-09-26 15:59 ` sashiko-bot
2026-09-25 15:57 ` [PATCH 7/8] soc: qcom: mdt_loader: remove qcom_mdt_load() Mukesh Ojha
2026-09-26 15:59 ` sashiko-bot
2026-09-25 15:57 ` [PATCH 8/8] firmware: qcom: pas: remove qcom_pas_auth_and_reset() Mukesh Ojha
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=20260926155935.D7FDD1F000FF@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=media-ci@linuxtv.org \
--cc=mukesh.ojha@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.