Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758429AbcDHM7N (ORCPT ); Fri, 8 Apr 2016 08:59:13 -0400 Received: from mail-pf0-f176.google.com ([209.85.192.176]:33871 "EHLO mail-pf0-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752421AbcDHM7L (ORCPT ); Fri, 8 Apr 2016 08:59:11 -0400 From: Chunyan Zhang To: alexander.shishkin@linux.intel.com Cc: linux-kernel@vger.kernel.org, zhang.lyra@gmail.com, mathieu.poirier@linaro.org Subject: [PATCH v2] stm class: correct masterID range in setting via sysfs Date: Fri, 8 Apr 2016 20:58:16 +0800 Message-Id: <1460120296-1794-1-git-send-email-zhang.chunyan@linaro.org> X-Mailer: git-send-email 1.9.1 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1264 Lines: 31 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 | 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