From patchwork Wed Apr 20 10:43:15 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Shishkin X-Patchwork-Id: 66210 Delivered-To: patch@linaro.org Received: by 10.140.93.198 with SMTP id d64csp2368440qge; Wed, 20 Apr 2016 03:44:38 -0700 (PDT) X-Received: by 10.98.53.6 with SMTP id c6mr11081351pfa.57.1461149078364; Wed, 20 Apr 2016 03:44:38 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ya3si4708533pab.2.2016.04.20.03.44.37; Wed, 20 Apr 2016 03:44:38 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932105AbcDTKog (ORCPT + 29 others); Wed, 20 Apr 2016 06:44:36 -0400 Received: from mga14.intel.com ([192.55.52.115]:14841 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933617AbcDTKn7 (ORCPT ); Wed, 20 Apr 2016 06:43:59 -0400 Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga103.fm.intel.com with ESMTP; 20 Apr 2016 03:43:48 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.24,509,1455004800"; d="scan'208";a="88562538" Received: from um.fi.intel.com (HELO localhost) ([10.237.72.212]) by fmsmga004.fm.intel.com with ESMTP; 20 Apr 2016 03:43:46 -0700 From: Alexander Shishkin To: Greg KH Cc: Mathieu Poirier , Chunyan Zhang , laurent.fert@intel.com, yann.fouassier@intel.com, linux-kernel@vger.kernel.org, Alexander Shishkin Subject: [QUEUED v20160420 02/19] stm class: Fix integer boundary checks for master range Date: Wed, 20 Apr 2016 13:43:15 +0300 Message-Id: <1461149012-26954-3-git-send-email-alexander.shishkin@linux.intel.com> X-Mailer: git-send-email 2.8.0.rc3 In-Reply-To: <1461149012-26954-1-git-send-email-alexander.shishkin@linux.intel.com> References: <1461149012-26954-1-git-send-email-alexander.shishkin@linux.intel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Chunyan Zhang Master IDs are of unsigned int type, yet in the configfs policy code we're validating user's input against INT_MAX. This is both pointless and misleading as the real limits are imposed by the stm device's [sw_start..sw_end] (which are also limited by the spec to be no larger than 2^16-1). Clean this up by getting rid of the redundant comparisons. Signed-off-by: Chunyan Zhang Signed-off-by: Alexander Shishkin Reviewed-by: Laurent Fert --- drivers/hwtracing/stm/policy.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) -- 2.8.0.rc3 diff --git a/drivers/hwtracing/stm/policy.c b/drivers/hwtracing/stm/policy.c index 1db189657b..e8b50b1ac6 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;