* [PATCH v2 2/3] coresight: tnoc: Fix fwnode reference leak on probe failure
@ 2026-11-26 15:57 Yige Jiang
2026-11-27 11:18 ` James Clark
0 siblings, 1 reply; 2+ messages in thread
From: Yige Jiang @ 2026-11-26 15:57 UTC (permalink / raw)
To: Suzuki K Poulose, Alexander Shishkin
Cc: Yige Jiang, Mike Leach, James Clark, Leo Yan, coresight,
linux-arm-kernel, linux-kernel
_tnoc_probe() parses the output connections before allocating driver
data, enabling clocks, mapping registers and setting up the trace ID.
If any of these steps fails, probe returns before coresight_register()
can take ownership of the destination fwnode references.
Get the platform data after trace ID setup. On either lookup or
registration failure, return the ID if the AMBA device acquired one.
The platform-device variant does not allocate a trace ID.
Codex helped trace the two probe paths and draft their shared cleanup.
Fixes: e54a52a28a36 ("coresight: add coresight Trace Network On Chip driver")
Suggested-by: James Clark <james.clark@linaro.org>
Signed-off-by: Yige Jiang <yigejiang86@gmail.com>
---
v2: Add the TNOC fix identified during review of the TPDM patch.
v1: https://lore.kernel.org/all/rc-b1-20261110-vc-178-2d9055f946c8@gmail.com/
Review: https://lore.kernel.org/all/e06bd559-c8c5-4e82-8951-9f7894cfb378@linaro.org/
Compile-tested: arm64, GCC 14.2.0, W=1, coresight-tnoc.o.
The baseline and patched objects built without warnings.
No hardware or runtime tests were performed.
drivers/hwtracing/coresight/coresight-tnoc.c | 22 +++++++++++++-------
1 file changed, 14 insertions(+), 8 deletions(-)
diff --git a/drivers/hwtracing/coresight/coresight-tnoc.c b/drivers/hwtracing/coresight/coresight-tnoc.c
index ec28b439d73d083ffa0de52ef454a9cd54b88175..2f3e2044676358925233c59ff3977fa36555c2c3 100644
--- a/drivers/hwtracing/coresight/coresight-tnoc.c
+++ b/drivers/hwtracing/coresight/coresight-tnoc.c
@@ -191,11 +191,6 @@ static int _tnoc_probe(struct device *dev, struct resource *res)
if (!desc.name)
return -ENOMEM;
- pdata = coresight_get_platform_data(dev);
- if (IS_ERR(pdata))
- return PTR_ERR(pdata);
- dev->platform_data = pdata;
-
drvdata = devm_kzalloc(dev, sizeof(*drvdata), GFP_KERNEL);
if (!drvdata)
return -ENOMEM;
@@ -217,6 +212,13 @@ static int _tnoc_probe(struct device *dev, struct resource *res)
if (ret)
return ret;
+ pdata = coresight_get_platform_data(dev);
+ if (IS_ERR(pdata)) {
+ ret = PTR_ERR(pdata);
+ goto err_put_id;
+ }
+ dev->platform_data = pdata;
+
desc.ops = &trace_noc_cs_ops;
desc.type = CORESIGHT_DEV_TYPE_LINK;
desc.subtype.link_subtype = CORESIGHT_DEV_SUBTYPE_LINK_MERG;
@@ -226,12 +228,16 @@ static int _tnoc_probe(struct device *dev, struct resource *res)
desc.groups = coresight_tnoc_groups;
drvdata->csdev = coresight_register(&desc);
if (IS_ERR(drvdata->csdev)) {
- if (drvdata->atid > 0)
- coresight_trace_id_put_system_id(drvdata->atid);
- return PTR_ERR(drvdata->csdev);
+ ret = PTR_ERR(drvdata->csdev);
+ goto err_put_id;
}
return 0;
+
+err_put_id:
+ if (drvdata->atid > 0)
+ coresight_trace_id_put_system_id(drvdata->atid);
+ return ret;
}
static int trace_noc_probe(struct amba_device *adev, const struct amba_id *id)
base-commit: b7d7462c7f973b65de511db6bebb99fb29946ed8
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v2 2/3] coresight: tnoc: Fix fwnode reference leak on probe failure
2026-11-26 15:57 [PATCH v2 2/3] coresight: tnoc: Fix fwnode reference leak on probe failure Yige Jiang
@ 2026-11-27 11:18 ` James Clark
0 siblings, 0 replies; 2+ messages in thread
From: James Clark @ 2026-11-27 11:18 UTC (permalink / raw)
To: Yige Jiang
Cc: Mike Leach, Leo Yan, coresight, linux-arm-kernel, linux-kernel,
Suzuki K Poulose, Alexander Shishkin
On 26/11/2026 15:57, Yige Jiang wrote:
> _tnoc_probe() parses the output connections before allocating driver
> data, enabling clocks, mapping registers and setting up the trace ID.
> If any of these steps fails, probe returns before coresight_register()
> can take ownership of the destination fwnode references.
>
> Get the platform data after trace ID setup. On either lookup or
> registration failure, return the ID if the AMBA device acquired one.
> The platform-device variant does not allocate a trace ID.
>
> Codex helped trace the two probe paths and draft their shared cleanup.
>
> Fixes: e54a52a28a36 ("coresight: add coresight Trace Network On Chip driver")
> Suggested-by: James Clark <james.clark@linaro.org>
> Signed-off-by: Yige Jiang <yigejiang86@gmail.com>
> ---
> v2: Add the TNOC fix identified during review of the TPDM patch.
>
The threading is broken for the patchset. Check out the b4 tools, they
handle patch creation and sending properly.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-27 12:21 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-26 15:57 [PATCH v2 2/3] coresight: tnoc: Fix fwnode reference leak on probe failure Yige Jiang
2026-11-27 11:18 ` James Clark
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox