From: sashiko-bot@kernel.org
To: "Mukesh Ojha" <mukesh.ojha@oss.qualcomm.com>
Cc: media-ci@linuxtv.org, dri-devel@lists.freedesktop.org
Subject: Re: [PATCH 5/8] net: ipa: migrate firmware loading to qcom_mdt_pas_load() and qcom_pas_prepare_and_auth_reset()
Date: Sat, 26 Sep 2026 15:59:36 +0000 [thread overview]
Message-ID: <20260926155937.624D11F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260925155737.4161358-6-mukesh.ojha@oss.qualcomm.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] net: ipa: shmbridge setup bypassed due to uninitialized ctx->use_tzmem flag
- [Medium] net: ipa: memory leak of PAS metadata DMA buffer due to missing qcom_pas_metadata_release()
--
commit 5216b43b65b5b9e8f76798ae9a011c6d5ce85515
Author: Mukesh Ojha <mukesh.ojha@oss.qualcomm.com>
net: ipa: migrate firmware loading to qcom_mdt_pas_load() and qcom_pas_prepare_and_auth_reset()
This commit replaces open-coded memory mapping and firmware loading
sequences with devm_qcom_pas_context_alloc() and qcom_mdt_pas_load().
It then uses qcom_pas_prepare_and_auth_reset() with the goal of
performing the shmbridge prepare step required before TrustZone
authentication.
> diff --git a/drivers/net/ipa/ipa_main.c b/drivers/net/ipa/ipa_main.c
> index 14ac2d2faf7c2..6964395caedd9 100644
> --- a/drivers/net/ipa/ipa_main.c
> +++ b/drivers/net/ipa/ipa_main.c
[ ... ]
> @@ -615,24 +614,23 @@ static int ipa_firmware_load(struct device *dev)
> }
>
> phys = res.start;
> - size = (size_t)resource_size(&res);
> - virt = memremap(phys, size, MEMREMAP_WC);
> - if (!virt) {
> - dev_err(dev, "unable to remap firmware memory\n");
> - ret = -ENOMEM;
> + ctx = devm_qcom_pas_context_alloc(dev, IPA_PAS_ID, phys,
> + resource_size(&res));
> + if (IS_ERR(ctx)) {
> + ret = PTR_ERR(ctx);
> goto out_release_firmware;
> }
[Severity: High]
Does allocating the context here leave the use_tzmem flag implicitly
initialized to false?
The commit message states the goal is to execute the shmbridge prepare
step. However, since devm_qcom_pas_context_alloc() allocates the context
using devm_kzalloc(), the ctx->use_tzmem boolean defaults to false.
When qcom_pas_prepare_and_auth_reset(ctx) is called later, the backend
evaluates this flag. If it is false, it falls back to the legacy
authentication path and completely bypasses the intended
qcom_tzmem_shm_bridge_create() logic.
Should ctx->use_tzmem be explicitly set to true after allocation?
>
> - ret = qcom_mdt_load(dev, fw, path, IPA_PAS_ID, virt, phys, size, NULL);
> + ret = qcom_mdt_pas_load(ctx, fw, path, NULL);
> if (ret) {
> dev_err(dev, "error %d loading \"%s\"\n", ret, path);
> - } else {
> - ret = qcom_pas_auth_and_reset(IPA_PAS_ID);
> - if (ret)
> - dev_err(dev, "error %d authenticating \"%s\"\n", ret, path);
> + goto out_release_firmware;
> }
>
> - memunmap(virt);
> + ret = qcom_pas_prepare_and_auth_reset(ctx);
> + if (ret)
> + dev_err(dev, "error %d authenticating \"%s\"\n", ret, path);
> +
> out_release_firmware:
> release_firmware(fw);
>
[Severity: Medium]
Will returning from this path leak the DMA buffer containing the firmware
metadata?
When qcom_mdt_pas_load() is called, it triggers the allocation and mapping
of a DMA buffer for the metadata, storing its address in ctx->ptr. While
the context structure itself is devres-managed, the underlying PAS backend
requires callers to explicitly free the metadata buffer.
If the function returns without calling qcom_pas_metadata_release(ctx),
does this result in a permanent memory leak of the metadata buffer on
every probe attempt?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260925155737.4161358-1-mukesh.ojha@oss.qualcomm.com?part=5
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
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 [this message]
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=20260926155937.624D11F000FF@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox