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 v3 4/9] media: iris: migrate firmware loading to qcom_mdt_pas_load() and qcom_pas_prepare_and_auth_reset()
Date: Tue, 17 Nov 2026 16:24:10 +0000 [thread overview]
Message-ID: <sashiko-outbox-219163@kernel.org> (raw)
In-Reply-To: <20261116162148.2864501-5-mukesh.ojha@oss.qualcomm.com>
Thank you for your contribution! Sashiko AI review found 3 potential
issues to consider:
- [High] media: iris: missing qcom_pas_metadata_release() in
iris_fw_load()
- [Medium] media: iris: unzeroed carveout memory scanned by
iris_detect_firmware()
- [Low] media: iris: missing kernel-doc entry for pas_ctx in struct
iris_core
--
commit 06c574841baf80a5b2f096e918c8cad3e79ad9f0
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()
This commit embeds a struct qcom_pas_context in struct iris_core and
migrates Iris firmware loading from qcom_mdt_load() and
qcom_pas_auth_and_reset() to qcom_mdt_pas_load() and
qcom_pas_prepare_and_auth_reset().
> diff --git a/drivers/media/platform/qcom/iris/iris_core.h b/drivers/media/platform/qcom/iris/iris_core.h
> index 3e4cf652bf39a..ac73bda072f85 100644
> --- a/drivers/media/platform/qcom/iris/iris_core.h
> +++ b/drivers/media/platform/qcom/iris/iris_core.h
[ ... ]
> @@ -129,6 +130,7 @@ struct iris_core {
> struct platform_inst_fw_cap inst_fw_caps_dec[INST_FW_CAP_MAX];
> struct platform_inst_fw_cap inst_fw_caps_enc[INST_FW_CAP_MAX];
> struct dma_iova_state *iova_state;
> + struct qcom_pas_context pas_ctx;
> };
[Severity: Low]
struct iris_core has a kernel-doc comment block describing its members, so
adding pas_ctx without an @pas_ctx entry will trigger a kernel-doc warning.
> diff --git a/drivers/media/platform/qcom/iris/iris_firmware.c b/drivers/media/platform/qcom/iris/iris_firmware.c
> index 21f57d37da187..b701a7f43514b 100644
> --- a/drivers/media/platform/qcom/iris/iris_firmware.c
> +++ b/drivers/media/platform/qcom/iris/iris_firmware.c
> @@ -201,21 +201,20 @@ static int iris_load_fw_to_memory(struct iris_core *core)
> goto err_release_fw;
> }
>
> - mem_virt = memremap(mem_phys, res_size, MEMREMAP_WC);
> - if (!mem_virt) {
> - ret = -ENOMEM;
> - goto err_release_fw;
> - }
> -
> - memset(mem_virt, 0, res_size);
> -
> - ret = qcom_mdt_load(dev, firmware, fw_name,
> - IRIS_PAS_ID, mem_virt, mem_phys, res_size, NULL);
> + qcom_pas_context_init(&core->pas_ctx, dev, IRIS_PAS_ID, mem_phys,
> + res_size);
> +
> + ret = qcom_mdt_pas_load(&core->pas_ctx, firmware, fw_name, NULL);
> + if (!ret) {
> + mem_virt = memremap(mem_phys, res_size, MEMREMAP_WC);
> + if (!mem_virt) {
> + ret = -ENOMEM;
> + goto err_release_fw;
> + }
>
> - if (!ret)
> iris_detect_firmware(core, fw_name, mem_virt, res_size, desc);
> -
> - memunmap(mem_virt);
> + memunmap(mem_virt);
> + }
[Severity: Medium]
Can removing memset(mem_virt, 0, res_size) cause iris_detect_firmware() to
scan uninitialized carveout memory?
qcom_mdt_pas_load() -> qcom_mdt_load_no_init() only populates individual
PT_LOAD segments and their BSS tails, leaving inter-segment gaps and the
trailing [fw_size, res_size) region untouched. When iris_detect_firmware()
subsequently scans all res_size bytes via iris_detect_gen2_from_fwdata() on
a dual-generation platform with a firmware-name override, stale data in the
unwritten carveout (for example after a warm reboot or prior Gen2 load) can
cause a smaller Gen1 firmware image to be misclassified as Gen2.
[ ... ]
> @@ -233,7 +232,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;
[Severity: High]
As reported by Konrad Dybcio on v1 [1], does this leak the PAS metadata
buffer stored in core->pas_ctx.ptr?
Unlike qcom_mdt_load(), which passes a NULL context to
__qcom_mdt_pas_init(), qcom_mdt_pas_load() passes &core->pas_ctx to
qcom_pas_init_image(), which retains the allocated DMA or TEE metadata
buffer in core->pas_ctx.ptr:
drivers/firmware/qcom/qcom_scm.c:qcom_scm_pas_init_image() {
...
if (ret < 0 || !ctx) {
dma_free_coherent(dev, size, mdata_buf, mdata_phys);
} else if (ctx) {
ctx->ptr = mdata_buf;
ctx->phys = mdata_phys;
ctx->size = size;
}
...
}
Neither qcom_pas_prepare_and_auth_reset() nor iris_firmware.c calls
qcom_pas_metadata_release(&core->pas_ctx), so the metadata buffer is leaked
on every firmware load (and overwritten when qcom_pas_context_init() zeroes
core->pas_ctx on subsequent loads or error recovery).
[1] https://lore.kernel.org/r/ce3f58f7-f500-49f8-89cd-611d8e1ac6ac@oss.qualcomm.com
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261116162148.2864501-1-mukesh.ojha@oss.qualcomm.com?part=4
next prev parent reply other threads:[~2026-11-17 16:24 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-16 16:21 [PATCH v3 0/9] Migrate PAS clients to qcom_mdt_pas_load() and qcom_pas_prepare_and_auth_reset() Mukesh Ojha
2026-11-16 16:21 ` [PATCH v3 1/9] firmware: qcom: pas: add qcom_pas_context_init() for pre-allocated context Mukesh Ojha
2026-11-16 16:21 ` [PATCH v3 2/9] remoteproc: qcom_wcnss: migrate to qcom_mdt_pas_load() and qcom_pas_prepare_and_auth_reset() Mukesh Ojha
2026-11-16 16:21 ` [PATCH v3 3/9] drm/msm/adreno: migrate zap shader loading " Mukesh Ojha
2026-11-17 16:24 ` sashiko-bot
2026-11-16 16:21 ` [PATCH v3 4/9] media: iris: migrate firmware " Mukesh Ojha
2026-11-17 16:24 ` sashiko-bot [this message]
2026-11-16 16:21 ` [PATCH v3 5/9] media: venus: " Mukesh Ojha
2026-11-17 16:24 ` sashiko-bot
2026-11-16 16:21 ` [PATCH v3 6/9] net: ipa: " Mukesh Ojha
2026-11-17 16:24 ` sashiko-bot
2026-11-16 16:21 ` [PATCH v3 7/9] wifi: ath12k: " Mukesh Ojha
2026-11-17 16:24 ` sashiko-bot
2026-11-16 16:21 ` [PATCH v3 8/9] soc: qcom: mdt_loader: remove qcom_mdt_load() Mukesh Ojha
2026-11-17 16:24 ` sashiko-bot
2026-11-16 16:21 ` [PATCH v3 9/9] 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=sashiko-outbox-219163@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.