drivers/hwtracing/coresight/coresight-core.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
The coresight_etm_get_trace_id function is a global function. The
verification process for 'csdev' is required prior to its usage.
Fixes: c367a89dec26 ("Coresight: Add trace_id function to retrieving the trace ID")
Signed-off-by: Jie Gan <quic_jiegan@quicinc.com>
---
drivers/hwtracing/coresight/coresight-core.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/drivers/hwtracing/coresight/coresight-core.c b/drivers/hwtracing/coresight/coresight-core.c
index bd0a7edd38c9..5a7cd2376e2d 100644
--- a/drivers/hwtracing/coresight/coresight-core.c
+++ b/drivers/hwtracing/coresight/coresight-core.c
@@ -1616,9 +1616,12 @@ EXPORT_SYMBOL_GPL(coresight_remove_driver);
int coresight_etm_get_trace_id(struct coresight_device *csdev, enum cs_mode mode,
struct coresight_device *sink)
{
- int trace_id;
- int cpu = source_ops(csdev)->cpu_id(csdev);
+ int cpu, trace_id;
+
+ if (csdev->type != CORESIGHT_DEV_TYPE_SOURCE && !source_ops(csdev)->cpu_id)
+ return -EINVAL;
+ cpu = source_ops(csdev)->cpu_id(csdev);
switch (mode) {
case CS_MODE_SYSFS:
trace_id = coresight_trace_id_get_cpu_id(cpu);
--
2.34.1
On 10/03/2025 02:23, Jie Gan wrote:
> The coresight_etm_get_trace_id function is a global function. The
> verification process for 'csdev' is required prior to its usage.
>
> Fixes: c367a89dec26 ("Coresight: Add trace_id function to retrieving the trace ID")
> Signed-off-by: Jie Gan <quic_jiegan@quicinc.com>
> ---
> drivers/hwtracing/coresight/coresight-core.c | 7 +++++--
> 1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/hwtracing/coresight/coresight-core.c b/drivers/hwtracing/coresight/coresight-core.c
> index bd0a7edd38c9..5a7cd2376e2d 100644
> --- a/drivers/hwtracing/coresight/coresight-core.c
> +++ b/drivers/hwtracing/coresight/coresight-core.c
> @@ -1616,9 +1616,12 @@ EXPORT_SYMBOL_GPL(coresight_remove_driver);
> int coresight_etm_get_trace_id(struct coresight_device *csdev, enum cs_mode mode,
> struct coresight_device *sink)
> {
> - int trace_id;
> - int cpu = source_ops(csdev)->cpu_id(csdev);
> + int cpu, trace_id;
> +
> + if (csdev->type != CORESIGHT_DEV_TYPE_SOURCE && !source_ops(csdev)->cpu_id)
That must be :
csdev->type != CORESIGHT_DEV_TYPE_SOURCE || !source_ops(csdev)->cpu_id)
Suzuki
> + return -EINVAL;
>
> + cpu = source_ops(csdev)->cpu_id(csdev);
> switch (mode) {
> case CS_MODE_SYSFS:
> trace_id = coresight_trace_id_get_cpu_id(cpu);
On 3/10/2025 6:17 PM, Suzuki K Poulose wrote:
> On 10/03/2025 02:23, Jie Gan wrote:
>> The coresight_etm_get_trace_id function is a global function. The
>> verification process for 'csdev' is required prior to its usage.
>>
>> Fixes: c367a89dec26 ("Coresight: Add trace_id function to retrieving
>> the trace ID")
>> Signed-off-by: Jie Gan <quic_jiegan@quicinc.com>
>> ---
>> drivers/hwtracing/coresight/coresight-core.c | 7 +++++--
>> 1 file changed, 5 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/hwtracing/coresight/coresight-core.c b/drivers/
>> hwtracing/coresight/coresight-core.c
>> index bd0a7edd38c9..5a7cd2376e2d 100644
>> --- a/drivers/hwtracing/coresight/coresight-core.c
>> +++ b/drivers/hwtracing/coresight/coresight-core.c
>> @@ -1616,9 +1616,12 @@ EXPORT_SYMBOL_GPL(coresight_remove_driver);
>> int coresight_etm_get_trace_id(struct coresight_device *csdev, enum
>> cs_mode mode,
>> struct coresight_device *sink)
>> {
>> - int trace_id;
>> - int cpu = source_ops(csdev)->cpu_id(csdev);
>> + int cpu, trace_id;
>> +
>> + if (csdev->type != CORESIGHT_DEV_TYPE_SOURCE && !
>> source_ops(csdev)->cpu_id)
>
> That must be :
>
> csdev->type != CORESIGHT_DEV_TYPE_SOURCE || !source_ops(csdev)-
> >cpu_id)
>
>
> Suzuki
Hi Suzuki,
Yes, you are right. I made a big mistake. It should return an error
number if one of the conditions failed.
Sorry about that, will send another patch to fix it.
Thanks,
Jie
>
>
>> + return -EINVAL;
>> + cpu = source_ops(csdev)->cpu_id(csdev);
>> switch (mode) {
>> case CS_MODE_SYSFS:
>> trace_id = coresight_trace_id_get_cpu_id(cpu);
>
© 2016 - 2026 Red Hat, Inc.