Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: James Clark <james.clark@linaro.org>
To: Jie Gan <jie.gan@oss.qualcomm.com>
Cc: coresight@lists.linaro.org, linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org,
	Suzuki K Poulose <suzuki.poulose@arm.com>,
	Mike Leach <mike.leach@arm.com>, Leo Yan <leo.yan@arm.com>,
	Alexander Shishkin <alexander.shishkin@linux.intel.com>,
	Tingwei Zhang <tingwei.zhang@oss.qualcomm.com>
Subject: Re: [PATCH] coresight: fix missing error code when trace ID is invalid
Date: Fri, 8 May 2026 09:25:00 +0100	[thread overview]
Message-ID: <c4828e79-ca07-420a-96d8-069489658cdd@linaro.org> (raw)
In-Reply-To: <20260508-fix-trace-id-error-v1-1-5f11a5456fdf@oss.qualcomm.com>



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)) {
> +		ret = -EINVAL;
>   		goto err_path;
> +	}
>   
>   	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>



  reply	other threads:[~2026-05-08  8:25 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-08  5:45 [PATCH] coresight: fix missing error code when trace ID is invalid Jie Gan
2026-05-08  8:25 ` James Clark [this message]
2026-05-08 13:44 ` Leo Yan
2026-05-08 13:53   ` Jie Gan
2026-05-08 14:00   ` Suzuki K Poulose

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=c4828e79-ca07-420a-96d8-069489658cdd@linaro.org \
    --to=james.clark@linaro.org \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=coresight@lists.linaro.org \
    --cc=jie.gan@oss.qualcomm.com \
    --cc=leo.yan@arm.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mike.leach@arm.com \
    --cc=suzuki.poulose@arm.com \
    --cc=tingwei.zhang@oss.qualcomm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox