[PATCH v4 7/8] coresight: Do not mix success path with failure handling

From: Leo Yan

Date: Mon Feb 09 2026 - 07:46:26 EST


Separate the failure handling path from the successful case. Use the
'out_unlock' label only for failure handling.

Reviewed-by: James Clark <james.clark@xxxxxxxxxx>
Signed-off-by: Leo Yan <leo.yan@xxxxxxx>
---
drivers/hwtracing/coresight/coresight-core.c | 21 +++++++++++++--------
1 file changed, 13 insertions(+), 8 deletions(-)

diff --git a/drivers/hwtracing/coresight/coresight-core.c b/drivers/hwtracing/coresight/coresight-core.c
index c694b4bea3d724464e97a4932ead584d59d8a69a..955af43010446803030973c72f07315492b2fcf3 100644
--- a/drivers/hwtracing/coresight/coresight-core.c
+++ b/drivers/hwtracing/coresight/coresight-core.c
@@ -1398,17 +1398,22 @@ struct coresight_device *coresight_register(struct coresight_desc *desc)
registered = true;

ret = coresight_create_conns_sysfs_group(csdev);
- if (!ret)
- ret = coresight_fixup_orphan_conns(csdev);
+ if (ret)
+ goto out_unlock;
+
+ ret = coresight_fixup_orphan_conns(csdev);
+ if (ret)
+ goto out_unlock;
+
+ mutex_unlock(&coresight_mutex);
+
+ if (cti_assoc_ops && cti_assoc_ops->add)
+ cti_assoc_ops->add(csdev);
+
+ return csdev;

out_unlock:
mutex_unlock(&coresight_mutex);
- /* Success */
- if (!ret) {
- if (cti_assoc_ops && cti_assoc_ops->add)
- cti_assoc_ops->add(csdev);
- return csdev;
- }

/* Unregister the device if needed */
if (registered) {

--
2.34.1