* [PATCH RESEND v2] coresight: etm4x: Fix mis-usage of nr_resource in sysfs interface
@ 2020-09-15 2:53 Jonathan Zhou
2020-09-15 16:42 ` Mathieu Poirier
0 siblings, 1 reply; 3+ messages in thread
From: Jonathan Zhou @ 2020-09-15 2:53 UTC (permalink / raw)
To: linux-arm-kernel
Cc: Mathieu Poirier, Suzuki K Poulose, lizixian, Shaokun Zhang,
Jonathan Zhou, Mike Leach
The member @nr_resource represents how many resource selector pairs,
and the pair 0 is always implemented and reserved.
So let's multiply by 2 when resetting the seletor configuration.
And also update the validation of the input @idx.
Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
Cc: Suzuki K Poulose <suzuki.poulose@arm.com>
Cc: Mike Leach <mike.leach@linaro.org>
Cc: Shaokun Zhang <zhangshaokun@hisilicon.com>
Cc: lizixian@hisilicon.com
Signed-off-by: Jonathan Zhou <jonathan.zhouwen@huawei.com>
---
ChangeLog in v2:
* Address Mathieu's comments.
drivers/hwtracing/coresight/coresight-etm4x-sysfs.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/drivers/hwtracing/coresight/coresight-etm4x-sysfs.c b/drivers/hwtracing/coresight/coresight-etm4x-sysfs.c
index b673e738bc9a..e4f1f659000d 100644
--- a/drivers/hwtracing/coresight/coresight-etm4x-sysfs.c
+++ b/drivers/hwtracing/coresight/coresight-etm4x-sysfs.c
@@ -236,7 +236,7 @@ static ssize_t reset_store(struct device *dev,
}
config->res_idx = 0x0;
- for (i = 0; i < drvdata->nr_resource; i++)
+ for (i = 2; i < 2 * drvdata->nr_resource; i++)
config->res_ctrl[i] = 0x0;
config->ss_idx = 0x0;
@@ -1663,8 +1663,11 @@ static ssize_t res_idx_store(struct device *dev,
if (kstrtoul(buf, 16, &val))
return -EINVAL;
- /* Resource selector pair 0 is always implemented and reserved */
- if ((val == 0) || (val >= drvdata->nr_resource))
+ /*
+ * Resource selector pair 0 is always implemented and reserved,
+ * namely an idx with 0 and 1 is illegal.
+ */
+ if ((val < 2) || (val >= 2 * drvdata->nr_resource))
return -EINVAL;
/*
--
1.9.1
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH RESEND v2] coresight: etm4x: Fix mis-usage of nr_resource in sysfs interface
2020-09-15 2:53 [PATCH RESEND v2] coresight: etm4x: Fix mis-usage of nr_resource in sysfs interface Jonathan Zhou
@ 2020-09-15 16:42 ` Mathieu Poirier
2020-09-16 8:05 ` Jonathan Zhou
0 siblings, 1 reply; 3+ messages in thread
From: Mathieu Poirier @ 2020-09-15 16:42 UTC (permalink / raw)
To: Jonathan Zhou
Cc: Shaokun Zhang, lizixian, Mike Leach, linux-arm-kernel,
Suzuki K Poulose
On Tue, Sep 15, 2020 at 10:53:57AM +0800, Jonathan Zhou wrote:
> The member @nr_resource represents how many resource selector pairs,
> and the pair 0 is always implemented and reserved.
> So let's multiply by 2 when resetting the seletor configuration.
> And also update the validation of the input @idx.
>
> Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
> Cc: Suzuki K Poulose <suzuki.poulose@arm.com>
> Cc: Mike Leach <mike.leach@linaro.org>
> Cc: Shaokun Zhang <zhangshaokun@hisilicon.com>
> Cc: lizixian@hisilicon.com
> Signed-off-by: Jonathan Zhou <jonathan.zhouwen@huawei.com>
> ---
> ChangeLog in v2:
> * Address Mathieu's comments.
>
> drivers/hwtracing/coresight/coresight-etm4x-sysfs.c | 9 ++++++---
> 1 file changed, 6 insertions(+), 3 deletions(-)
You send me two identical patches on the same day - the only difference was the
RESEND had an capital 'f' in "Fix". That's the one I applied.
Thanks,
Mathieu
>
> diff --git a/drivers/hwtracing/coresight/coresight-etm4x-sysfs.c b/drivers/hwtracing/coresight/coresight-etm4x-sysfs.c
> index b673e738bc9a..e4f1f659000d 100644
> --- a/drivers/hwtracing/coresight/coresight-etm4x-sysfs.c
> +++ b/drivers/hwtracing/coresight/coresight-etm4x-sysfs.c
> @@ -236,7 +236,7 @@ static ssize_t reset_store(struct device *dev,
> }
>
> config->res_idx = 0x0;
> - for (i = 0; i < drvdata->nr_resource; i++)
> + for (i = 2; i < 2 * drvdata->nr_resource; i++)
> config->res_ctrl[i] = 0x0;
>
> config->ss_idx = 0x0;
> @@ -1663,8 +1663,11 @@ static ssize_t res_idx_store(struct device *dev,
>
> if (kstrtoul(buf, 16, &val))
> return -EINVAL;
> - /* Resource selector pair 0 is always implemented and reserved */
> - if ((val == 0) || (val >= drvdata->nr_resource))
> + /*
> + * Resource selector pair 0 is always implemented and reserved,
> + * namely an idx with 0 and 1 is illegal.
> + */
> + if ((val < 2) || (val >= 2 * drvdata->nr_resource))
> return -EINVAL;
>
> /*
> --
> 1.9.1
>
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH RESEND v2] coresight: etm4x: Fix mis-usage of nr_resource in sysfs interface
2020-09-15 16:42 ` Mathieu Poirier
@ 2020-09-16 8:05 ` Jonathan Zhou
0 siblings, 0 replies; 3+ messages in thread
From: Jonathan Zhou @ 2020-09-16 8:05 UTC (permalink / raw)
To: Mathieu Poirier
Cc: Shaokun Zhang, lizixian, Mike Leach, linux-arm-kernel,
Suzuki K Poulose
On 16/09/2020 00:42, Mathieu Poirier wrote:
> On Tue, Sep 15, 2020 at 10:53:57AM +0800, Jonathan Zhou wrote:
>> The member @nr_resource represents how many resource selector pairs,
>> and the pair 0 is always implemented and reserved.
>> So let's multiply by 2 when resetting the seletor configuration.
>> And also update the validation of the input @idx.
>>
>> Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
>> Cc: Suzuki K Poulose <suzuki.poulose@arm.com>
>> Cc: Mike Leach <mike.leach@linaro.org>
>> Cc: Shaokun Zhang <zhangshaokun@hisilicon.com>
>> Cc: lizixian@hisilicon.com
>> Signed-off-by: Jonathan Zhou <jonathan.zhouwen@huawei.com>
>> ---
>> ChangeLog in v2:
>> * Address Mathieu's comments.
>>
>> drivers/hwtracing/coresight/coresight-etm4x-sysfs.c | 9 ++++++---
>> 1 file changed, 6 insertions(+), 3 deletions(-)
>
> You send me two identical patches on the same day - the only difference was the
> RESEND had an capital 'f' in "Fix". That's the one I applied.
>
Very sorry for sending this patch twice. I saw your revise for my
previous patch, so I am trying to keep the latter patches in line with
the norms.
Regards.
Jonathan
> Thanks,
> Mathieu
>
>
>>
>> diff --git a/drivers/hwtracing/coresight/coresight-etm4x-sysfs.c b/drivers/hwtracing/coresight/coresight-etm4x-sysfs.c
>> index b673e738bc9a..e4f1f659000d 100644
>> --- a/drivers/hwtracing/coresight/coresight-etm4x-sysfs.c
>> +++ b/drivers/hwtracing/coresight/coresight-etm4x-sysfs.c
>> @@ -236,7 +236,7 @@ static ssize_t reset_store(struct device *dev,
>> }
>>
>> config->res_idx = 0x0;
>> - for (i = 0; i < drvdata->nr_resource; i++)
>> + for (i = 2; i < 2 * drvdata->nr_resource; i++)
>> config->res_ctrl[i] = 0x0;
>>
>> config->ss_idx = 0x0;
>> @@ -1663,8 +1663,11 @@ static ssize_t res_idx_store(struct device *dev,
>>
>> if (kstrtoul(buf, 16, &val))
>> return -EINVAL;
>> - /* Resource selector pair 0 is always implemented and reserved */
>> - if ((val == 0) || (val >= drvdata->nr_resource))
>> + /*
>> + * Resource selector pair 0 is always implemented and reserved,
>> + * namely an idx with 0 and 1 is illegal.
>> + */
>> + if ((val < 2) || (val >= 2 * drvdata->nr_resource))
>> return -EINVAL;
>>
>> /*
>> --
>> 1.9.1
>>
> .
>
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-09-16 8:06 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-09-15 2:53 [PATCH RESEND v2] coresight: etm4x: Fix mis-usage of nr_resource in sysfs interface Jonathan Zhou
2020-09-15 16:42 ` Mathieu Poirier
2020-09-16 8:05 ` Jonathan Zhou
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox