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 5/9] media: venus: migrate firmware loading to qcom_mdt_pas_load() and qcom_pas_prepare_and_auth_reset()
Date: Tue, 17 Nov 2026 16:24:11 +0000 [thread overview]
Message-ID: <sashiko-outbox-219164@kernel.org> (raw)
In-Reply-To: <20261116162148.2864501-6-mukesh.ojha@oss.qualcomm.com>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] media: venus: PAS metadata buffer leak in venus_load_fw() and
venus_boot()
--
commit 197c5c883871fbbcc35bb55913a4e0eb4bf2cd11
Author: Mukesh Ojha <mukesh.ojha@oss.qualcomm.com>
media: venus: 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 video_firmware and
switches the TrustZone firmware loading path in venus_load_fw() and
venus_boot() to qcom_mdt_pas_load() and qcom_pas_prepare_and_auth_reset().
> diff --git a/drivers/media/platform/qcom/venus/firmware.c b/drivers/media/platform/qcom/venus/firmware.c
> index 3a38ff985822f..704343e241dc6 100644
> --- a/drivers/media/platform/qcom/venus/firmware.c
> +++ b/drivers/media/platform/qcom/venus/firmware.c
> @@ -117,21 +117,22 @@ static int venus_load_fw(struct venus_core *core, const char *fwname,
> goto err_release_fw;
> }
>
> - mem_va = memremap(*mem_phys, *mem_size, MEMREMAP_WC);
> - if (!mem_va) {
> - dev_err(dev, "unable to map memory region %pa size %#zx\n", mem_phys, *mem_size);
> - ret = -ENOMEM;
> - goto err_release_fw;
> - }
> -
> - if (core->use_tz)
> - ret = qcom_mdt_load(dev, mdt, fwname, VENUS_PAS_ID,
> - mem_va, *mem_phys, *mem_size, NULL);
> - else
> + if (core->use_tz) {
> + qcom_pas_context_init(&core->fw.pas_ctx, dev, VENUS_PAS_ID,
> + *mem_phys, *mem_size);
> + ret = qcom_mdt_pas_load(&core->fw.pas_ctx, mdt, fwname, NULL);
> + } else {
> + mem_va = memremap(*mem_phys, *mem_size, MEMREMAP_WC);
> + if (!mem_va) {
> + dev_err(dev, "unable to map memory region %pa size %#zx\n",
> + mem_phys, *mem_size);
> + ret = -ENOMEM;
> + goto err_release_fw;
> + }
> ret = qcom_mdt_load_no_init(dev, mdt, fwname, mem_va,
> *mem_phys, *mem_size, NULL);
> -
> - memunmap(mem_va);
> + memunmap(mem_va);
> + }
> err_release_fw:
> release_firmware(mdt);
> return ret;
> @@ -237,7 +238,7 @@ int venus_boot(struct venus_core *core)
> core->fw.mem_phys = mem_phys;
>
> if (core->use_tz)
> - ret = qcom_pas_auth_and_reset(VENUS_PAS_ID);
> + ret = qcom_pas_prepare_and_auth_reset(&core->fw.pas_ctx);
> else
> ret = venus_boot_no_tz(core, mem_phys, mem_size);
[Severity: Medium]
As reported by Konrad Dybcio on v1 [1], does this leak the PAS metadata
buffer in core->fw.pas_ctx.ptr?
Unlike qcom_mdt_load(), which passes a NULL context to
qcom_pas_init_image() so the metadata buffer is freed immediately,
qcom_mdt_pas_load() passes &core->fw.pas_ctx, causing
qcom_pas_init_image() to retain the metadata allocation in
core->fw.pas_ctx.ptr until qcom_pas_metadata_release() is called.
Nothing calls qcom_pas_metadata_release(&core->fw.pas_ctx) after
qcom_pas_prepare_and_auth_reset() or if qcom_mdt_pas_load() fails after
qcom_pas_init_image() succeeds, and subsequent recovery boots via
venus_sys_error_handler() -> venus_boot() overwrite core->fw.pas_ctx in
qcom_pas_context_init().
[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=5
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
2026-11-16 16:21 ` [PATCH v3 5/9] media: venus: " Mukesh Ojha
2026-11-17 16:24 ` sashiko-bot [this message]
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-219164@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.