On 08/05/2026 6:45 am, Jie Gan wrote:
When coresight_path_assign_trace_id() fails to allocate a valid trace ID, the code jumps to err_path without setting ret to an error value. This causes coresight_enable_sysfs() to return 0 (success) to the caller even though no trace session was started.
Set ret = -EINVAL before the goto so that callers receive a proper error code.
Fixes: d87d76d823d1 ("Coresight: Allocate trace ID after building the path") Signed-off-by: Jie Gan jie.gan@oss.qualcomm.com
drivers/hwtracing/coresight/coresight-sysfs.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/hwtracing/coresight/coresight-sysfs.c b/drivers/hwtracing/coresight/coresight-sysfs.c index d2a6ed8bcc74..c9338c783540 100644 --- a/drivers/hwtracing/coresight/coresight-sysfs.c +++ b/drivers/hwtracing/coresight/coresight-sysfs.c @@ -195,42 +195,44 @@ int coresight_enable_sysfs(struct coresight_device *csdev) */ if (subtype == CORESIGHT_DEV_SUBTYPE_SOURCE_SOFTWARE) csdev->refcnt++; goto out; } sink = coresight_find_activated_sysfs_sink(csdev); if (!sink) { ret = -EINVAL; goto out; } path = coresight_build_path(csdev, sink); if (IS_ERR(path)) { pr_err("building path(s) failed\n"); ret = PTR_ERR(path); goto out; } coresight_path_assign_trace_id(path, CS_MODE_SYSFS);
- if (!IS_VALID_CS_TRACE_ID(path->trace_id))
- if (!IS_VALID_CS_TRACE_ID(path->trace_id)) {
goto err_path;ret = -EINVAL;- }
ret = coresight_enable_path(path, CS_MODE_SYSFS); if (ret) goto err_path; ret = coresight_enable_source_sysfs(csdev, CS_MODE_SYSFS, path); if (ret) goto err_source; switch (subtype) { case CORESIGHT_DEV_SUBTYPE_SOURCE_PROC: /* * When working from sysFS it is important to keep track * of the paths that were created so that they can be * undone in 'coresight_disable()'. Since there can only * be a single session per tracer (when working from sysFS) * a per-cpu variable will do just fine. */ cpu = source_ops(csdev)->cpu_id(csdev); per_cpu(tracer_path, cpu) = path;
base-commit: 17c7841d09ee7d33557fd075562d9289b6018c90 change-id: 20260508-fix-trace-id-error-dbfdd4d8f2d1
Best regards,
Reviewed-by: James Clark james.clark@linaro.org