From: sashiko-bot@kernel.org
To: "Anvesh Jain P" <anvesh.p@oss.qualcomm.com>
Cc: devicetree@vger.kernel.org, robh@kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH v2 2/4] remoteproc: qcom: pas: Support secondary images
Date: Thu, 15 Oct 2026 06:05:21 +0000 [thread overview]
Message-ID: <sashiko-outbox-172329@kernel.org> (raw)
In-Reply-To: <20261015-oob-support-glymur-v2-2-715435f52dd7@oss.qualcomm.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] qcom_q6v5_pas: NULL pointer dereference due to early returns bypassing context allocations
- [Medium] qcom_q6v5_pas: Memory leak of firmware objects on successful load
--
commit 3f3270df945541b7e62ff38a77d04e462e6bf823
Author: Anvesh Jain P <anvesh.p@oss.qualcomm.com>
remoteproc: qcom: pas: Support secondary images
The PAS remoteproc driver currently supports one primary image and its
optional DTB. OOBMSS additionally requires the secondary image and DTB
to be loaded, authenticated, mapped, shut down, and released through
their own PAS identifiers and carveouts.
> diff --git a/drivers/remoteproc/qcom_q6v5_pas.c b/drivers/remoteproc/qcom_q6v5_pas.c
> index ca8e61254c449..0bce2f0d5b4aa 100644
> --- a/drivers/remoteproc/qcom_q6v5_pas.c
> +++ b/drivers/remoteproc/qcom_q6v5_pas.c
[ ... ]
> @@ -241,19 +281,29 @@ static int qcom_pas_load(struct rproc *rproc, const struct firmware *fw)
> if (pas->lite_dtb_pas_id)
> qcom_pas_shutdown(pas->lite_dtb_pas_id);
>
> - if (pas->dtb_pas_id) {
> - ret = request_firmware(&pas->dtb_firmware, pas->dtb_firmware_name, pas->dev);
> + if (pas->secondary_dtb_pas_id) {
> + ret = request_firmware(&pas->secondary_dtb_firmware,
> + pas->secondary_dtb_firmware_name, pas->dev);
> + if (ret) {
> + qcom_pas_release_firmware(pas);
> + return ret;
> + }
> + }
> +
> + if (pas->secondary_pas_id) {
> + ret = request_firmware(&pas->secondary_firmware,
> + pas->secondary_firmware_name, pas->dev);
> if (ret) {
> - dev_err(pas->dev, "request_firmware failed for %s: %d\n",
> - pas->dtb_firmware_name, ret);
> + qcom_pas_release_firmware(pas);
> return ret;
> }
> + }
>
> - ret = qcom_mdt_pas_load(pas->dtb_pas_ctx, pas->dtb_firmware,
> - pas->dtb_firmware_name, &pas->dtb_mem_reloc);
> + if (pas->dtb_pas_id) {
> + ret = request_firmware(&pas->dtb_firmware, pas->dtb_firmware_name,
> + pas->dev);
> if (ret) {
> - qcom_pas_metadata_release(pas->dtb_pas_ctx);
> - release_firmware(pas->dtb_firmware);
> + qcom_pas_release_firmware(pas);
> return ret;
> }
> }
[Severity: Medium]
When qcom_pas_load() completes successfully, it returns 0 without calling
release_firmware() or qcom_pas_release_firmware(). Could this leak the
firmware objects and their underlying buffers?
[ ... ]
> @@ -344,13 +435,16 @@ static int qcom_pas_start(struct rproc *rproc)
> ret = qcom_q6v5_wait_for_start(&pas->q6v5, msecs_to_jiffies(5000));
> if (ret == -ETIMEDOUT) {
> dev_err(pas->dev, "start timed out\n");
> - qcom_pas_shutdown(pas->pas_id);
> goto unmap_carveout;
> }
>
> qcom_pas_metadata_release(pas->pas_ctx);
> if (pas->dtb_pas_id)
> qcom_pas_metadata_release(pas->dtb_pas_ctx);
> + if (pas->secondary_pas_id)
> + qcom_pas_metadata_release(pas->secondary_pas_ctx);
> + if (pas->secondary_dtb_pas_id)
> + qcom_pas_metadata_release(pas->secondary_dtb_pas_ctx);
>
> /* firmware is used to pass reference from qcom_pas_start(), drop it now */
> pas->firmware = NULL;
> @@ -358,16 +452,37 @@ static int qcom_pas_start(struct rproc *rproc)
> return 0;
[Severity: Medium]
Similarly, in the success path of qcom_pas_start(), should there be a call
to release the secondary_dtb_firmware, secondary_firmware, and dtb_firmware
objects before returning 0?
[ ... ]
> @@ -740,6 +876,42 @@ static int qcom_pas_alloc_memory_region(struct qcom_pas *pas)
> if (IS_ERR(pas->dtb_pas_ctx))
> return PTR_ERR(pas->dtb_pas_ctx);
>
> + if (!pas->secondary_pas_id)
> + return 0;
[Severity: High]
In qcom_pas_alloc_memory_region() (just before this diff hunk), there is an
early return:
if (!pas->dtb_pas_id)
return 0;
If a platform defines a secondary_pas_id but lacks a primary dtb_pas_id, will
this early return prevent the allocation of the secondary contexts?
> +
> + ret = of_reserved_mem_region_to_resource(pas->dev->of_node, 2, &res);
> + if (ret)
> + return ret;
> +
> + pas->secondary_mem_phys = res.start;
> + pas->secondary_mem_reloc = res.start;
> + pas->secondary_mem_size = resource_size(&res);
> +
> + pas->secondary_pas_ctx =
> + devm_qcom_pas_context_alloc(pas->dev, pas->secondary_pas_id,
> + pas->secondary_mem_phys,
> + pas->secondary_mem_size);
> + if (IS_ERR(pas->secondary_pas_ctx))
> + return PTR_ERR(pas->secondary_pas_ctx);
[ ... ]
> @@ -925,6 +1125,10 @@ static int qcom_pas_probe(struct platform_device *pdev)
> pas->pas_ctx->use_tzmem = desc->needs_tzmem || rproc->has_iommu;
> if (pas->dtb_pas_id)
> pas->dtb_pas_ctx->use_tzmem = desc->needs_tzmem || rproc->has_iommu;
> + if (pas->secondary_pas_id)
> + pas->secondary_pas_ctx->use_tzmem = desc->needs_tzmem || rproc->has_iommu;
[Severity: High]
If qcom_pas_alloc_memory_region() returned early because dtb_pas_id was
missing, could pas->secondary_pas_ctx be NULL here, leading to a NULL pointer
dereference when setting use_tzmem?
> + if (pas->secondary_dtb_pas_id)
> + pas->secondary_dtb_pas_ctx->use_tzmem = desc->needs_tzmem || rproc->has_iommu;
>
> if (desc->early_boot)
> pas->rproc->state = RPROC_DETACHED;
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261015-oob-support-glymur-v2-0-715435f52dd7@oss.qualcomm.com?part=2
next prev parent reply other threads:[~2026-10-15 6:05 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-15 5:55 [PATCH v2 0/4] Add Glymur OOBMSS support Anvesh Jain P
2026-10-15 5:55 ` [PATCH v2 1/4] dt-bindings: remoteproc: qcom: Add Glymur OOBMSS PAS Anvesh Jain P
2026-10-15 10:34 ` Krzysztof Kozlowski
2026-10-15 5:55 ` [PATCH v2 2/4] remoteproc: qcom: pas: Support secondary images Anvesh Jain P
2026-10-15 6:05 ` sashiko-bot [this message]
2026-10-15 9:57 ` Anvesh Jain P
2026-10-15 5:55 ` [PATCH v2 3/4] remoteproc: qcom: pas: Add coredump support for secondary processors Anvesh Jain P
2026-10-15 6:13 ` sashiko-bot
2026-10-15 5:55 ` [PATCH v2 4/4] remoteproc: qcom: pas: Add Glymur OOBMSS PAS parameters Anvesh Jain P
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-172329@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=anvesh.p@oss.qualcomm.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=robh@kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox