All of lore.kernel.org
 help / color / mirror / Atom feed
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 7/9] wifi: ath12k: migrate firmware loading to qcom_mdt_pas_load() and qcom_pas_prepare_and_auth_reset()
Date: Tue, 17 Nov 2026 16:24:12 +0000	[thread overview]
Message-ID: <sashiko-outbox-219166@kernel.org> (raw)
In-Reply-To: <20261116162148.2864501-8-mukesh.ojha@oss.qualcomm.com>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [High] wifi: ath12k: PAS metadata leak in ath12k_ahb_power_up() and
  shared FW load
--

commit dad01e3cbb75f83eee2677fffc757868fad930d0
Author: Mukesh Ojha <mukesh.ojha@oss.qualcomm.com>

wifi: ath12k: migrate firmware loading to qcom_mdt_pas_load() and qcom_pas_prepare_and_auth_reset()

This commit replaces qcom_mdt_load() and qcom_pas_auth_and_reset() in
ath12k_ahb_power_up() and ath12k_ahb_load_auth_shared_fw() with
qcom_pas_context_init(), qcom_mdt_pas_load(), and
qcom_pas_prepare_and_auth_reset().

> diff --git a/drivers/net/wireless/ath/ath12k/ahb.c b/drivers/net/wireless/ath/ath12k/ahb.c
> index 2c55aae06dd06..355f1f5509975 100644
> --- a/drivers/net/wireless/ath/ath12k/ahb.c
> +++ b/drivers/net/wireless/ath/ath12k/ahb.c
> @@ -411,6 +411,7 @@ static int ath12k_ahb_power_up(struct ath12k_base *ab)
>  	struct ath12k_ahb_rproc_info *rproc_info = ab_ahb->rproc_info;
>  	char fw_name[ATH12K_USERPD_FW_NAME_LEN];
>  	char fw2_name[ATH12K_USERPD_FW_NAME_LEN];
> +	struct qcom_pas_context ctx;
>  	struct device *dev = ab->dev;
>  	const struct firmware *fw, *fw2;
>  	unsigned long time_left;
> @@ -444,14 +445,15 @@ static int ath12k_ahb_power_up(struct ath12k_base *ab)
>  		ATH12K_AHB_UPD_SWID;
>  
>  	/* Load FW image to a reserved memory location */
> -	if (ab_ahb->scm_auth_enabled)
> -		ret = qcom_mdt_load(dev, fw, fw_name, pasid, rproc_info->mem_region,
> -				    rproc_info->mem_phys, rproc_info->mem_size,
> -				    NULL);
> -	else
> +	if (ab_ahb->scm_auth_enabled) {
> +		qcom_pas_context_init(&ctx, dev, pasid,
> +				      rproc_info->mem_phys, rproc_info->mem_size);
> +		ret = qcom_mdt_pas_load(&ctx, fw, fw_name, NULL);
> +	} else {
>  		ret = qcom_mdt_load_no_init(dev, fw, fw_name, rproc_info->mem_region,
>  					    rproc_info->mem_phys, rproc_info->mem_size,
>  					    NULL);
> +	}
>  	if (ret) {
>  		ath12k_err(ab, "Failed to load MDT segments: %d\n", ret);
>  		goto err_fw;
> @@ -485,7 +487,7 @@ static int ath12k_ahb_power_up(struct ath12k_base *ab)
>  
>  	if (ab_ahb->scm_auth_enabled) {
>  		/* Authenticate FW image using peripheral ID */
> -		ret = qcom_pas_auth_and_reset(pasid);
> +		ret = qcom_pas_prepare_and_auth_reset(&ctx);
>  		if (ret) {
>  			ath12k_err(ab, "failed to boot the remote processor %d\n", ret);
>  			goto err_fw2;
> @@ -1023,6 +1025,7 @@ static int ath12k_ahb_load_auth_shared_fw(struct ath12k_base *ab,
>  					  struct ath12k_ahb_rproc_info *rproc_info,
>  					  const char *fw_name, u32 pasid)
>  {
> +	struct qcom_pas_context ctx;
>  	int ret;
>  
>  	const struct firmware *fw __free(firmware) = NULL;
> @@ -1041,14 +1044,16 @@ static int ath12k_ahb_load_auth_shared_fw(struct ath12k_base *ab,
>  	ath12k_dbg(ab, ATH12K_DBG_AHB, "loading firmware %s, size %zd\n", fw_name,
>  		   fw->size);
>  
> -	ret = qcom_mdt_load(ab->dev, fw, fw_name, pasid, rproc_info->mem_region,
> -			    rproc_info->mem_phys, rproc_info->mem_size, NULL);
> +	qcom_pas_context_init(&ctx, ab->dev, pasid,
> +			      rproc_info->mem_phys, rproc_info->mem_size);
> +
> +	ret = qcom_mdt_pas_load(&ctx, fw, fw_name, NULL);
>  	if (ret) {
>  		ath12k_err(ab, "failed to load RO firmware %s: %d\n", fw_name, ret);
>  		return ret;
>  	}
>  
> -	ret = qcom_pas_auth_and_reset(pasid);
> +	ret = qcom_pas_prepare_and_auth_reset(&ctx);
>  	if (ret)
>  		ath12k_err(ab, "failed to authenticate and boot shared firmware: %d\n",
>  			   ret);

[Severity: High]
Does this leak the PAS metadata buffer stored in ctx.ptr in both
ath12k_ahb_power_up() and ath12k_ahb_load_auth_shared_fw()?

Previously, qcom_mdt_load() passed a NULL context pointer to
__qcom_mdt_pas_init() -> qcom_pas_init_image(), which caused the backend
to free the metadata buffer immediately.  qcom_mdt_pas_load() instead
passes &ctx to qcom_pas_init_image(), which retains the allocated
metadata buffer in 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_mdt_pas_load() nor qcom_pas_prepare_and_auth_reset() frees
this allocation, so ctx goes out of scope and leaks the metadata memory
on every firmware load and error unwind path unless
qcom_pas_metadata_release(&ctx) is called.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261116162148.2864501-1-mukesh.ojha@oss.qualcomm.com?part=7

  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
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 [this message]
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-219166@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.