Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] coresight: add verification process for coresight_etm_get_trace_id
@ 2025-03-10  2:23 Jie Gan
  2025-03-10 10:17 ` Suzuki K Poulose
  0 siblings, 1 reply; 3+ messages in thread
From: Jie Gan @ 2025-03-10  2:23 UTC (permalink / raw)
  To: Suzuki K Poulose, Mike Leach, James Clark, Alexander Shishkin
  Cc: Tingwei Zhang, Jinlong Mao, coresight, linux-arm-kernel,
	linux-kernel, linux-arm-msm, Jie Gan

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



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] coresight: add verification process for coresight_etm_get_trace_id
  2025-03-10  2:23 [PATCH] coresight: add verification process for coresight_etm_get_trace_id Jie Gan
@ 2025-03-10 10:17 ` Suzuki K Poulose
  2025-03-10 10:19   ` Jie Gan
  0 siblings, 1 reply; 3+ messages in thread
From: Suzuki K Poulose @ 2025-03-10 10:17 UTC (permalink / raw)
  To: Jie Gan, Mike Leach, James Clark, Alexander Shishkin
  Cc: Tingwei Zhang, Jinlong Mao, coresight, linux-arm-kernel,
	linux-kernel, linux-arm-msm

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);



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] coresight: add verification process for coresight_etm_get_trace_id
  2025-03-10 10:17 ` Suzuki K Poulose
@ 2025-03-10 10:19   ` Jie Gan
  0 siblings, 0 replies; 3+ messages in thread
From: Jie Gan @ 2025-03-10 10:19 UTC (permalink / raw)
  To: Suzuki K Poulose, Mike Leach, James Clark, Alexander Shishkin
  Cc: Tingwei Zhang, Jinlong Mao, coresight, linux-arm-kernel,
	linux-kernel, linux-arm-msm



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);
> 



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-03-10 11:35 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-10  2:23 [PATCH] coresight: add verification process for coresight_etm_get_trace_id Jie Gan
2025-03-10 10:17 ` Suzuki K Poulose
2025-03-10 10:19   ` Jie Gan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox