All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Vishnu Reddy" <busanna.reddy@oss.qualcomm.com>
Cc: conor+dt@kernel.org, devicetree@vger.kernel.org, robh@kernel.org,
	media-ci@linuxtv.org
Subject: Re: [PATCH v10 06/14] media: iris: Enable Secure PAS support with IOMMU managed by Linux
Date: Sun, 26 Jul 2026 06:08:43 +0000	[thread overview]
Message-ID: <20260726060844.53A711F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260726-glymur-v10-6-de451559e88b@oss.qualcomm.com>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] Incomplete Implementation / Dead Code: `core->fw_dev` is never assigned, rendering the direct IOMMU mapping feature entirely dead code.
- [Medium] Potential NULL pointer dereference of `core->pas_ctx` in `iris_fw_iommu_unmap` during asynchronous error cleanup.
--

--- Patch [6]: [PATCH v10 06/14] media: iris: Enable Secure PAS support with IOMMU managed by Linux ---
commit 4079c73feb157bb490aaa33ca1d6e4970df1c4f7
Author: Mukesh Ojha <mukesh.ojha@oss.qualcomm.com>

media: iris: Enable Secure PAS support with IOMMU managed by Linux

On platforms without a hypervisor, Linux handles the SMC mapping and brings up
the co-processor directly. This patch adds support to the Iris driver to
manage the firmware context device and IOMMU mapping directly when the
firmware device SID is present.

Link: https://lore.kernel.org/lkml/20260105-kvmrprocv10-v10-0-022e96815380@oss.qualcomm.com/

> diff --git a/drivers/media/platform/qcom/iris/iris_core.h b/drivers/media/platform/qcom/iris/iris_core.h
> --- a/drivers/media/platform/qcom/iris/iris_core.h
> +++ b/drivers/media/platform/qcom/iris/iris_core.h
> @@ -85,6 +87,8 @@ struct iris_core {
>  	struct device				*dev;
>  	struct device				*np_dev;
>  	struct device				*p_dev;
> +	struct device				*fw_dev;
> +	struct qcom_pas_context			*pas_ctx;
>  	void __iomem				*reg_base;

[ ... ]

> diff --git a/drivers/media/platform/qcom/iris/iris_firmware.c b/drivers/media/platform/qcom/iris/iris_firmware.c
> --- a/drivers/media/platform/qcom/iris/iris_firmware.c
> +++ b/drivers/media/platform/qcom/iris/iris_firmware.c

[ ... ]

> @@ -53,9 +65,23 @@ static int iris_load_fw_to_memory(struct iris_core *core, const char *fw_name)
>  		goto err_release_fw;
>  	}
>  
> -	ret = qcom_mdt_load(dev, firmware, fw_name,
> -			    IRIS_PAS_ID, mem_virt, mem_phys, res_size, NULL);
> +	core->pas_ctx->use_tzmem = !!core->fw_dev;

[Severity: High]
Is core->fw_dev ever assigned a value in the driver?

It appears to be declared in struct iris_core, which is zero-initialized,
but I don't see any logic populating it anywhere in the codebase. Because it
remains NULL, !!core->fw_dev will always be false. Does this unintentionally
make the subsequent direct IOMMU mapping logic unreachable dead code?

> +	ret = qcom_mdt_pas_load(core->pas_ctx, firmware, fw_name, mem_virt, NULL);
> +	if (ret)
> +		goto err_mem_unmap;
> +
> +	if (core->pas_ctx->use_tzmem) {
> +		domain = iommu_get_domain_for_dev(fw_dev);

[ ... ]

> +static void iris_fw_iommu_unmap(struct iris_core *core)
> +{
> +	struct iommu_domain *domain;
> +
> +	if (!core->fw_dev)
> +		return;
> +
> +	domain = iommu_get_domain_for_dev(core->fw_dev);
> +	if (domain)
> +		iommu_unmap(domain, IRIS_FW_START_ADDR, core->pas_ctx->mem_size);

[Severity: Medium]
Could this lead to a NULL pointer dereference on core->pas_ctx if
core->fw_dev is properly initialized in the future?

If an early failure occurs during iris_load_fw_to_memory (for instance, if
of_reserved_mem_region_to_resource fails), core->pas_ctx is never allocated.
If a hardware watchdog or spurious interrupt fires concurrently,
iris_hfi_isr_handler could overwrite the state to IRIS_CORE_ERROR and
schedule iris_sys_error_handler. The error handler calls iris_core_deinit()
followed by iris_fw_unload(), which invokes this function.

Should there be a check to ensure core->pas_ctx is non-NULL before
accessing core->pas_ctx->mem_size?

> +}
> +
>  int iris_fw_load(struct iris_core *core)
>  {

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260726-glymur-v10-0-de451559e88b@oss.qualcomm.com?part=6

  reply	other threads:[~2026-07-26  6:08 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-26  5:49 [PATCH v10 00/14] media: iris: Add support for glymur platform Vishnu Reddy
2026-07-26  5:49 ` [PATCH v10 01/14] dt-bindings: media: qcom,glymur-iris: Add glymur video codec Vishnu Reddy
2026-07-26  6:00   ` sashiko-bot
2026-07-26  5:49 ` [PATCH v10 02/14] media: iris: Add hooks to initialize and tear down context banks Vishnu Reddy
2026-07-26  6:01   ` sashiko-bot
2026-07-26  5:49 ` [PATCH v10 03/14] media: iris: Add helper to create a context bank device Vishnu Reddy
2026-07-26  6:03   ` sashiko-bot
2026-07-26  5:49 ` [PATCH v10 04/14] media: iris: Add helper to select relevant " Vishnu Reddy
2026-07-26  6:11   ` sashiko-bot
2026-07-26  5:49 ` [PATCH v10 05/14] media: iris: Skip DMA mask setting to core device when IOMMU is not mapped Vishnu Reddy
2026-07-26  6:05   ` sashiko-bot
2026-07-26  5:49 ` [PATCH v10 06/14] media: iris: Enable Secure PAS support with IOMMU managed by Linux Vishnu Reddy
2026-07-26  6:08   ` sashiko-bot [this message]
2026-07-26  5:49 ` [PATCH v10 07/14] media: iris: Replace enum-indexed clock and power domain tables with per-block structures Vishnu Reddy
2026-07-26  6:06   ` sashiko-bot
2026-07-26  5:49 ` [PATCH v10 08/14] media: iris: Add power sequence for glymur Vishnu Reddy
2026-07-26  6:05   ` sashiko-bot
2026-07-26  5:49 ` [PATCH v10 09/14] media: iris: Handle CPU_CS_SCIACMDARG3 register write via program bootup registers hook Vishnu Reddy
2026-07-26  6:03   ` sashiko-bot
2026-07-26  5:49 ` [PATCH v10 10/14] media: iris: Add support to select core for dual core platforms Vishnu Reddy
2026-07-26  6:18   ` sashiko-bot
2026-07-26  5:49 ` [PATCH v10 11/14] media: iris: Add hooks for pixel and non-pixel context banks Vishnu Reddy
2026-07-26  6:03   ` sashiko-bot
2026-07-26  5:49 ` [PATCH v10 12/14] media: iris: Add platform data for glymur Vishnu Reddy
2026-07-26  5:49 ` [PATCH v10 13/14] arm64: dts: qcom: glymur: Add iris video node Vishnu Reddy
2026-07-26  5:49 ` [PATCH v10 14/14] arm64: dts: qcom: glymur-crd: Enable iris video codec node Vishnu Reddy

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=20260726060844.53A711F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=busanna.reddy@oss.qualcomm.com \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=media-ci@linuxtv.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 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.