* [PATCH] stm class: correct masterID range in setting via sysfs
@ 2016-03-28 7:55 Chunyan Zhang
2016-03-31 13:43 ` Alexander Shishkin
2016-04-08 11:53 ` Alexander Shishkin
0 siblings, 2 replies; 4+ messages in thread
From: Chunyan Zhang @ 2016-03-28 7:55 UTC (permalink / raw)
To: alexander.shishkin; +Cc: linux-kernel, mathieu.poirier, zhang.lyra
The type of masterID is defined as 'unsigned int', theoretically one
can set masterID with a number larger than 'INT_MAX' as long as
'stm_data::sw_end' is larger than 'INT_MAX'.
Also, 'stm_data::start' and 'stm_data::end' is initialized in respective
drivers which should be able to use any value less than 'UINT_MAX' for
their masterIDs, of course including those values larger than 'INT_MAX',
but the current policy is wrongly assuming that masterIDs would not be
larger than 'INT_MAX'. This patch just corrected that.
Signed-off-by: Chunyan Zhang <zhang.chunyan@linaro.org>
---
drivers/hwtracing/stm/policy.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/hwtracing/stm/policy.c b/drivers/hwtracing/stm/policy.c
index 1db1896..ce3edfd 100644
--- a/drivers/hwtracing/stm/policy.c
+++ b/drivers/hwtracing/stm/policy.c
@@ -107,7 +107,7 @@ stp_policy_node_masters_store(struct config_item *item, const char *page,
goto unlock;
/* must be within [sw_start..sw_end], which is an inclusive range */
- if (first > INT_MAX || last > INT_MAX || first > last ||
+ if (first > UINT_MAX || last > UINT_MAX || first > last ||
first < stm->data->sw_start ||
last > stm->data->sw_end) {
ret = -ERANGE;
--
1.9.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] stm class: correct masterID range in setting via sysfs
2016-03-28 7:55 [PATCH] stm class: correct masterID range in setting via sysfs Chunyan Zhang
@ 2016-03-31 13:43 ` Alexander Shishkin
2016-04-08 11:53 ` Alexander Shishkin
1 sibling, 0 replies; 4+ messages in thread
From: Alexander Shishkin @ 2016-03-31 13:43 UTC (permalink / raw)
To: Chunyan Zhang; +Cc: linux-kernel, mathieu.poirier, zhang.lyra
Chunyan Zhang <zhang.chunyan@linaro.org> writes:
> The type of masterID is defined as 'unsigned int', theoretically one
> can set masterID with a number larger than 'INT_MAX' as long as
> 'stm_data::sw_end' is larger than 'INT_MAX'.
>
> Also, 'stm_data::start' and 'stm_data::end' is initialized in respective
> drivers which should be able to use any value less than 'UINT_MAX' for
> their masterIDs, of course including those values larger than 'INT_MAX',
> but the current policy is wrongly assuming that masterIDs would not be
> larger than 'INT_MAX'. This patch just corrected that.
>
> Signed-off-by: Chunyan Zhang <zhang.chunyan@linaro.org>
Good catch, thanks!
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] stm class: correct masterID range in setting via sysfs
2016-03-28 7:55 [PATCH] stm class: correct masterID range in setting via sysfs Chunyan Zhang
2016-03-31 13:43 ` Alexander Shishkin
@ 2016-04-08 11:53 ` Alexander Shishkin
2016-04-08 12:40 ` Chunyan Zhang
1 sibling, 1 reply; 4+ messages in thread
From: Alexander Shishkin @ 2016-04-08 11:53 UTC (permalink / raw)
To: Chunyan Zhang; +Cc: linux-kernel, mathieu.poirier, zhang.lyra
Chunyan Zhang <zhang.chunyan@linaro.org> writes:
> The type of masterID is defined as 'unsigned int', theoretically one
> can set masterID with a number larger than 'INT_MAX' as long as
> 'stm_data::sw_end' is larger than 'INT_MAX'.
>
> Also, 'stm_data::start' and 'stm_data::end' is initialized in respective
> drivers which should be able to use any value less than 'UINT_MAX' for
> their masterIDs, of course including those values larger than 'INT_MAX',
> but the current policy is wrongly assuming that masterIDs would not be
> larger than 'INT_MAX'. This patch just corrected that.
>
> Signed-off-by: Chunyan Zhang <zhang.chunyan@linaro.org>
> ---
> drivers/hwtracing/stm/policy.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/hwtracing/stm/policy.c b/drivers/hwtracing/stm/policy.c
> index 1db1896..ce3edfd 100644
> --- a/drivers/hwtracing/stm/policy.c
> +++ b/drivers/hwtracing/stm/policy.c
> @@ -107,7 +107,7 @@ stp_policy_node_masters_store(struct config_item *item, const char *page,
> goto unlock;
>
> /* must be within [sw_start..sw_end], which is an inclusive range */
> - if (first > INT_MAX || last > INT_MAX || first > last ||
> + if (first > UINT_MAX || last > UINT_MAX || first > last ||
Of course, I wasn't paying attention, testing an unsigned integer for
being greater than UINT_MAX doesn't really make sense.
Regards,
--
Alex
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] stm class: correct masterID range in setting via sysfs
2016-04-08 11:53 ` Alexander Shishkin
@ 2016-04-08 12:40 ` Chunyan Zhang
0 siblings, 0 replies; 4+ messages in thread
From: Chunyan Zhang @ 2016-04-08 12:40 UTC (permalink / raw)
To: Alexander Shishkin; +Cc: linux-kernel, Mathieu Poirier, Lyra Zhang
On Fri, Apr 8, 2016 at 7:53 PM, Alexander Shishkin
<alexander.shishkin@linux.intel.com> wrote:
> Chunyan Zhang <zhang.chunyan@linaro.org> writes:
>
>> The type of masterID is defined as 'unsigned int', theoretically one
>> can set masterID with a number larger than 'INT_MAX' as long as
>> 'stm_data::sw_end' is larger than 'INT_MAX'.
>>
>> Also, 'stm_data::start' and 'stm_data::end' is initialized in respective
>> drivers which should be able to use any value less than 'UINT_MAX' for
>> their masterIDs, of course including those values larger than 'INT_MAX',
>> but the current policy is wrongly assuming that masterIDs would not be
>> larger than 'INT_MAX'. This patch just corrected that.
>>
>> Signed-off-by: Chunyan Zhang <zhang.chunyan@linaro.org>
>> ---
>> drivers/hwtracing/stm/policy.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/hwtracing/stm/policy.c b/drivers/hwtracing/stm/policy.c
>> index 1db1896..ce3edfd 100644
>> --- a/drivers/hwtracing/stm/policy.c
>> +++ b/drivers/hwtracing/stm/policy.c
>> @@ -107,7 +107,7 @@ stp_policy_node_masters_store(struct config_item *item, const char *page,
>> goto unlock;
>>
>> /* must be within [sw_start..sw_end], which is an inclusive range */
>> - if (first > INT_MAX || last > INT_MAX || first > last ||
>> + if (first > UINT_MAX || last > UINT_MAX || first > last ||
>
> Of course, I wasn't paying attention, testing an unsigned integer for
> being greater than UINT_MAX doesn't really make sense.
>
Ah right, checking first/last > INT/UINT_MAX is not needed actually.
Thanks for double review,
Chunyan
> Regards,
> --
> Alex
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2016-04-08 12:40 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-03-28 7:55 [PATCH] stm class: correct masterID range in setting via sysfs Chunyan Zhang
2016-03-31 13:43 ` Alexander Shishkin
2016-04-08 11:53 ` Alexander Shishkin
2016-04-08 12:40 ` Chunyan Zhang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®