From patchwork Mon Mar 28 07:55:42 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chunyan Zhang X-Patchwork-Id: 64520 Delivered-To: patch@linaro.org Received: by 10.112.199.169 with SMTP id jl9csp1315028lbc; Mon, 28 Mar 2016 00:56:46 -0700 (PDT) X-Received: by 10.66.162.193 with SMTP id yc1mr22349128pab.148.1459151806779; Mon, 28 Mar 2016 00:56:46 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id fb6si4644247pab.87.2016.03.28.00.56.46; Mon, 28 Mar 2016 00:56:46 -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; dkim=pass header.i=@linaro.org; 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 S1754577AbcC1H4b (ORCPT + 29 others); Mon, 28 Mar 2016 03:56:31 -0400 Received: from mail-pa0-f46.google.com ([209.85.220.46]:36136 "EHLO mail-pa0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754026AbcC1H4T (ORCPT ); Mon, 28 Mar 2016 03:56:19 -0400 Received: by mail-pa0-f46.google.com with SMTP id tt10so92772832pab.3 for ; Mon, 28 Mar 2016 00:56:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=VHDpUDj5bNsH9DILOBQumfsonojLxTRsz8HVCEZ36eU=; b=fH6XdwJGhN0ivZt11ZdO+ln2RSPSn+X3blHFaapaOL1uMq1wEHYPfaBkEzcqazTVP5 zxmW9QmpiGyJWHgHImImPPsIjOFS4prPABy2kZYvmATMVjrsorL6dUNb2PaZmM2BHpoA uZU1WWjRX0CeLxPS1UMzULkDGcohEHoQ+y0nk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=VHDpUDj5bNsH9DILOBQumfsonojLxTRsz8HVCEZ36eU=; b=ONyAVW5yo59gFtBcbRANK6SAx0VGWgdDuIt2p4aQY8fU9Ydp2GfuVtDbS61PuUs71P wMAOVtcoDKYT4Kc48CsY6vW0gexcDFgh6VbgsACLCI+PSZZCP3WVn8ymhzJ0eW90HJP3 DU+/JE532inMZbi4rJ3Cgx8zkuQLsPSu37HCQjSKGkw/xfizDw7eoU8yp1Um86cmZrdK AnkdyZKKAPSWcvxovUx0759EHoVzNXQi4Got1GgayJW6ssDYyiO5KMjSNQrAuQoK2TVd eezYb0C1arGRB4WOaoFIl+AtYMsbKeiVaNafv6lHo8WRFZcHRnMvcfazDrw4AFAA8dDw U+dA== X-Gm-Message-State: AD7BkJJYchygZKqHUk5NZRjX08YFqULMg8PHaL9e1Qi+GlOpqU2l8X+pTbWdCzNV9ZIG3+bq X-Received: by 10.67.8.100 with SMTP id dj4mr40678219pad.88.1459151778683; Mon, 28 Mar 2016 00:56:18 -0700 (PDT) Received: from zcy-ubuntu.spreadtrum.com ([175.111.195.49]) by smtp.gmail.com with ESMTPSA id 3sm33274074pfn.59.2016.03.28.00.56.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 28 Mar 2016 00:56:17 -0700 (PDT) From: Chunyan Zhang To: alexander.shishkin@linux.intel.com Cc: linux-kernel@vger.kernel.org, mathieu.poirier@linaro.org, zhang.lyra@gmail.com Subject: [PATCH] stm class: correct masterID range in setting via sysfs Date: Mon, 28 Mar 2016 15:55:42 +0800 Message-Id: <1459151742-31733-1-git-send-email-zhang.chunyan@linaro.org> X-Mailer: git-send-email 1.9.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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(-) -- 1.9.1 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;