[PATCH v3 1/3] coresight: tpdm: Fix fwnode reference leak on probe failure
From: Yige Jiang
Date: Wed Dec 02 2026 - 05:09:45 EST
coresight_get_platform_data() takes a reference to the destination
firmware node of each output connection. The core drops those references
on registration failure or when the device is unregistered. Device
resource cleanup alone does not release them.
tpdm_probe() can return before registration if driver data allocation,
MMIO mapping, dataset setup or device name allocation fails. Move the
platform data lookup after these steps so every successful lookup
reaches coresight_register().
Static analysis flagged the TPDM error paths.
Fixes: b3c71626a933 ("Coresight: Add coresight TPDM source driver")
Signed-off-by: Yige Jiang <yigejiang86@xxxxxxxxx>
---
drivers/hwtracing/coresight/coresight-tpdm.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/drivers/hwtracing/coresight/coresight-tpdm.c b/drivers/hwtracing/coresight/coresight-tpdm.c
index 8464edbba2d45efa5ba041dae70149a946c20465..f4b879bfca1a153f50012757e1b078605fa87944 100644
--- a/drivers/hwtracing/coresight/coresight-tpdm.c
+++ b/drivers/hwtracing/coresight/coresight-tpdm.c
@@ -1408,11 +1408,6 @@ static int tpdm_probe(struct device *dev, struct resource *res)
struct coresight_desc desc = { 0 };
int ret;
- pdata = coresight_get_platform_data(dev);
- if (IS_ERR(pdata))
- return PTR_ERR(pdata);
- dev->platform_data = pdata;
-
/* driver data*/
drvdata = devm_kzalloc(dev, sizeof(*drvdata), GFP_KERNEL);
if (!drvdata)
@@ -1448,6 +1443,12 @@ static int tpdm_probe(struct device *dev, struct resource *res)
desc.name = coresight_alloc_device_name("tpdm", dev);
if (!desc.name)
return -ENOMEM;
+
+ pdata = coresight_get_platform_data(dev);
+ if (IS_ERR(pdata))
+ return PTR_ERR(pdata);
+ dev->platform_data = pdata;
+
desc.type = CORESIGHT_DEV_TYPE_SOURCE;
desc.subtype.source_subtype = CORESIGHT_DEV_SUBTYPE_SOURCE_TPDM;
desc.ops = &tpdm_cs_ops;
base-commit: b7d7462c7f973b65de511db6bebb99fb29946ed8