]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
coresight: Do not mix success path with failure handling
authorLeo Yan <leo.yan@arm.com>
Mon, 9 Feb 2026 12:44:39 +0000 (12:44 +0000)
committerSuzuki K Poulose <suzuki.poulose@arm.com>
Wed, 25 Feb 2026 11:14:45 +0000 (11:14 +0000)
Separate the failure handling path from the successful case.  Use the
'out_unlock' label only for failure handling.

Reviewed-by: James Clark <james.clark@linaro.org>
Signed-off-by: Leo Yan <leo.yan@arm.com>
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
Link: https://lore.kernel.org/r/20260209-arm_coresight_refactor_dev_register-v4-7-62d6042f76f7@arm.com
drivers/hwtracing/coresight/coresight-core.c

index 6ddbc773330e592036ca45c84eeb46cc034670cb..e04545295240d5b25d233e75aa1bad5df0cab699 100644 (file)
@@ -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) {