Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1365378 > unrolled thread

[PATCH] stm class: correct masterID range in setting via sysfs

Started byChunyan Zhang <zhang.chunyan@linaro.org>
First post2016-03-28 10:00 +0200
Last post2016-03-31 15:50 +0200
Articles 2 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] stm class: correct masterID range in setting via sysfs Chunyan Zhang <zhang.chunyan@linaro.org> - 2016-03-28 10:00 +0200
    Re: [PATCH] stm class: correct masterID range in setting via sysfs Alexander Shishkin <alexander.shishkin@linux.intel.com> - 2016-03-31 15:50 +0200

#1365378 — [PATCH] stm class: correct masterID range in setting via sysfs

FromChunyan Zhang <zhang.chunyan@linaro.org>
Date2016-03-28 10:00 +0200
Subject[PATCH] stm class: correct masterID range in setting via sysfs
Message-ID<rhAfD-3PC-9@gated-at.bofh.it>
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

[toc] | [next] | [standalone]


#1368314

FromAlexander Shishkin <alexander.shishkin@linux.intel.com>
Date2016-03-31 15:50 +0200
Message-ID<riL90-5Qv-23@gated-at.bofh.it>
In reply to#1365378
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!

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web