Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758341AbcDHMkN (ORCPT ); Fri, 8 Apr 2016 08:40:13 -0400 Received: from mail-wm0-f52.google.com ([74.125.82.52]:33656 "EHLO mail-wm0-f52.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758283AbcDHMkL (ORCPT ); Fri, 8 Apr 2016 08:40:11 -0400 MIME-Version: 1.0 In-Reply-To: <87d1q0xqok.fsf@ashishki-desk.ger.corp.intel.com> References: <1459151742-31733-1-git-send-email-zhang.chunyan@linaro.org> <87d1q0xqok.fsf@ashishki-desk.ger.corp.intel.com> Date: Fri, 8 Apr 2016 20:40:10 +0800 Message-ID: Subject: Re: [PATCH] stm class: correct masterID range in setting via sysfs From: Chunyan Zhang To: Alexander Shishkin Cc: "linux-kernel@vger.kernel.org" , Mathieu Poirier , Lyra Zhang Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1658 Lines: 42 On Fri, Apr 8, 2016 at 7:53 PM, Alexander Shishkin wrote: > Chunyan Zhang 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 >> --- >> 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