]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
coresight: Fix source not disabled on idr_alloc_u32 failure
authorJie Gan <jie.gan@oss.qualcomm.com>
Fri, 15 May 2026 20:08:08 +0000 (21:08 +0100)
committerSuzuki K Poulose <suzuki.poulose@arm.com>
Mon, 18 May 2026 09:18:44 +0000 (10:18 +0100)
In coresight_enable_sysfs(), for non-CPU sources (SOFTWARE, TPDM,
OTHERS), the source device is enabled via coresight_enable_source_sysfs()
before idr_alloc_u32() maps the path. If idr_alloc_u32() fails, the
original code jumped directly to err_source, which only calls
coresight_disable_path() and coresight_release_path(). The source device
was left enabled with an incremented refcnt but no path tracked for it,
leaving the device in an inconsistent state.

Disable the source before jumping to err_source so the enable and path
operations are fully unwound.

Fixes: 5c0016d7b343 ("coresight: core: Use IDR for non-cpu bound sources' paths.")
Signed-off-by: Jie Gan <jie.gan@oss.qualcomm.com>
Reviewed-by: Yeoreum Yun <yeoreum.yun@arm.com>
Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
Link: https://lore.kernel.org/r/20260515-arm_coresight_path_power_management_improvement-v14-1-f88c4a3ecfe9@arm.com
drivers/hwtracing/coresight/coresight-sysfs.c

index b6a870399e83419dce0552099562fa3ae7b2bd69..da6f22b512c92ab0cff5bb239495a1ab6d2a0dbe 100644 (file)
@@ -244,8 +244,10 @@ int coresight_enable_sysfs(struct coresight_device *csdev)
                 */
                hash = hashlen_hash(hashlen_string(NULL, dev_name(&csdev->dev)));
                ret = idr_alloc_u32(&path_idr, path, &hash, hash, GFP_KERNEL);
-               if (ret)
+               if (ret) {
+                       coresight_disable_source_sysfs(csdev, NULL);
                        goto err_source;
+               }
                break;
        default:
                /* We can't be here */