Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Jie Gan" <jie.gan@oss.qualcomm.com>
Cc: devicetree@vger.kernel.org, robh@kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH v2 3/8] coresight: tmc: factor out common ETR probe initialisation
Date: Mon, 30 Nov 2026 07:20:32 +0000	[thread overview]
Message-ID: <sashiko-outbox-240581@kernel.org> (raw)
In-Reply-To: <20261130-introduce-qcom-qecp-feature-v2-3-dff9ae87327b@oss.qualcomm.com>

Thank you for your contribution! Sashiko AI review found no new issues
in this patch, but noticed 1 related pre-existing issue it does not
introduce:
- [High] coresight: tmc: invalid csdev access and resource leaks in
  __tmc_probe() [1]
--

commit 287401d1d1c361e6772a54be5797715a0d04a2cd
Author: Jie Gan <jie.gan@oss.qualcomm.com>

coresight: tmc: factor out common ETR probe initialisation

This commit moves the ETR probe setup derived from DEVID and firmware
properties into tmc_etr_probe_common(), leaving tmc_etr_setup_caps() with
the register-based checks.

> diff --git a/drivers/hwtracing/coresight/coresight-tmc-core.c b/drivers/hwtracing/coresight/coresight-tmc-core.c
> index 0ef4b817b297d..ad2c99eae5aed 100644
> --- a/drivers/hwtracing/coresight/coresight-tmc-core.c
> +++ b/drivers/hwtracing/coresight/coresight-tmc-core.c
[ ... ]
> @@ -829,11 +847,12 @@ static int __tmc_probe(struct device *dev, struct resource *res)
>  		desc.type = CORESIGHT_DEV_TYPE_SINK;
>  		desc.subtype.sink_subtype = CORESIGHT_DEV_SUBTYPE_SINK_SYSMEM;
>  		desc.ops = &tmc_etr_cs_ops;
> -		ret = tmc_etr_setup_caps(dev, devid, &desc.access);
> +		ret = tmc_etr_setup_caps(dev, &desc.access);
> +		if (ret)
> +			goto out;
> +		ret = tmc_etr_probe_common(dev, drvdata, devid);
>  		if (ret)
>  			goto out;
> -		idr_init(&drvdata->idr);
> -		mutex_init(&drvdata->idr_mutex);
>  		dev_list = "tmc_etr";
>  		break;
>  	case TMC_CONFIG_TYPE_ETF:

[Severity: High]
This problem wasn't introduced by this patch, but can jumping to out
after tmc_get_reserved_region() dereference an invalid drvdata->csdev
[1]?

drivers/hwtracing/coresight/coresight-tmc-core.c:__tmc_probe() {
    ...
out:
	if (is_tmc_crashdata_valid(drvdata) &&
	    !tmc_prepare_crashdata(drvdata))
		register_crash_dev_interface(drvdata, desc.name);
	return ret;
}

When probe fails after tmc_get_reserved_region() maps valid crash trace
data, the out path runs is_tmc_crashdata_valid(), tmc_prepare_crashdata(),
and register_crash_dev_interface().  All three dereference
&drvdata->csdev->dev while drvdata->csdev is still NULL, an ERR_PTR()
from coresight_register(), or already freed by coresight_unregister().

If register_crash_dev_interface() succeeds on an error path,
misc_register() also links drvdata->crashdev into misc_list right before
devres frees drvdata.  In addition, the unmanaged memremap() mappings in
drvdata->resrv_buf.vaddr and drvdata->crash_mdata.vaddr are never
unmapped on probe failure or in __tmc_remove().

[1] https://sashiko.dev/#/bug/linux-f23df7b7-bae5-4fa0-96ef-4e83632058e8

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261130-introduce-qcom-qecp-feature-v2-0-dff9ae87327b@oss.qualcomm.com?part=3

  reply	other threads:[~2026-11-30  7:20 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-30  7:11 [PATCH v2 0/8] Coresight: Introduce Qualcomm QDCP support for QECP-owned trace blocks Jie Gan
2026-11-30  7:11 ` [PATCH v2 1/8] soc: qcom: add QDCP client library Jie Gan
2026-11-30  7:11 ` [PATCH v2 2/8] coresight: tmc: split ETR buffer sync from hardware state readback Jie Gan
2026-11-30  7:11 ` [PATCH v2 3/8] coresight: tmc: factor out common ETR probe initialisation Jie Gan
2026-11-30  7:20   ` sashiko-bot [this message]
2026-11-30  7:11 ` [PATCH v2 4/8] coresight: tmc: move trigger_cntr into its own attribute group Jie Gan
2026-11-30  7:11 ` [PATCH v2 5/8] dt-bindings: arm: qcom: add QECP owned CoreSight STM Jie Gan
2026-11-30  7:11 ` [PATCH v2 6/8] coresight: qcom: add QECP owned STM driver Jie Gan
2026-11-30  7:11 ` [PATCH v2 7/8] dt-bindings: arm: qcom: add QECP owned CoreSight TMC Jie Gan
2026-11-30  7:11 ` [PATCH v2 8/8] coresight: tmc: add QECP owned TMC driver Jie Gan
2026-11-30  7:33   ` sashiko-bot

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-240581@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=jie.gan@oss.qualcomm.com \
    --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