* [PATCH v2] stm class: correct masterID range in setting via sysfs
@ 2016-04-08 12:58 Chunyan Zhang
2016-04-08 13:07 ` Alexander Shishkin
0 siblings, 1 reply; 2+ messages in thread
From: Chunyan Zhang @ 2016-04-08 12:58 UTC (permalink / raw)
To: alexander.shishkin; +Cc: linux-kernel, zhang.lyra, mathieu.poirier
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 | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/hwtracing/stm/policy.c b/drivers/hwtracing/stm/policy.c
index 1db1896..e8b50b1 100644
--- a/drivers/hwtracing/stm/policy.c
+++ b/drivers/hwtracing/stm/policy.c
@@ -107,8 +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 ||
- first < stm->data->sw_start ||
+ if (first > last || first < stm->data->sw_start ||
last > stm->data->sw_end) {
ret = -ERANGE;
goto unlock;
--
1.9.1
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH v2] stm class: correct masterID range in setting via sysfs
2016-04-08 12:58 [PATCH v2] stm class: correct masterID range in setting via sysfs Chunyan Zhang
@ 2016-04-08 13:07 ` Alexander Shishkin
0 siblings, 0 replies; 2+ messages in thread
From: Alexander Shishkin @ 2016-04-08 13:07 UTC (permalink / raw)
To: Chunyan Zhang; +Cc: linux-kernel, zhang.lyra, mathieu.poirier
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',
Actually, STP specification allows up to 65536 masters ([0..65535]), so
technically there's no problem. :)
The comparisons are still bogus, though. I'll amend your commit message.
Thanks,
--
Alex
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-04-08 13:07 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-04-08 12:58 [PATCH v2] stm class: correct masterID range in setting via sysfs Chunyan Zhang
2016-04-08 13:07 ` Alexander Shishkin
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®