Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp2006157ybn; Thu, 26 Sep 2019 05:42:30 -0700 (PDT) X-Google-Smtp-Source: APXvYqxYrxtzub7d6ohi+YwU/CxVHmzYiZf8KGSgwvaHAKdzA53xi30XMlxONGDLiDslDyJhjkdD X-Received: by 2002:a50:d0d5:: with SMTP id g21mr3401742edf.204.1569501750502; Thu, 26 Sep 2019 05:42:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569501750; cv=none; d=google.com; s=arc-20160816; b=tNsvGh5Dx9odajB0JNM+u9014TW/AWcHLK8D7W57sEOHmJkN2XXF8SwQhFoIkFBiMd z8RuUK6cq24V5knbDQXdK6ytOLjcBMecme2ybyebJZ1h59m32ifc8brnyUvfSsCJGzmj IVtvOYlqUctJ+54aYvdUBTfj94IRCX9VjiketqBeiRAgEzUxZcPd/NuryqS8UNjrEvNN XQfobRrRVFJNc0a9YQrHPrmeRF2pXXymEQRJRewb3ayXUDs+26EyKX+EdVZ5fsvwYo/y xhPPYMSYFGA+XFT6GJtg1UnRyg7Bssrest6+pBhJg1vKLObql1HTCtROZKZ8O046vxWo Fu+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:content-disposition :mime-version:message-id:subject:cc:to:from:date:dkim-signature; bh=YDRRpVAtUWoOxNUyo4YRN1dH81wF4V8OciFyOM/bsSc=; b=v83dET1eUa/ozAr9tMCsEE8sB0muuquRat/u23+5gnDiI1WgzhP8citoFo2xSkotJF e7WqvhtbMa8rbARsWKaKhNcJKmT+3hUM8k7Nx1cxsKx8qqvbgQdBPvKFeKyVTX/oVZgq HSCPWlD+bV//JgIBabXG/PmM4c7/l0f01jbdFGQk5vGuN4cJbHQD/nzYZAb7F2OT5oBp M1tRNYmvyLokz0B2A8l7Y8z3iLTwndoeKDurt+1XCEF/JbXPSffS9x9mCUPDfYIhNO+C zxWDI0owo6rKG5uU1bGi/yjJRMAnSlgpceOdpONCJvnBPgei76ORn48Nei2AcpKJso8h 8VlQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2019-08-05 header.b="KKTeV+/j"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k17si930734ejz.227.2019.09.26.05.42.06; Thu, 26 Sep 2019 05:42:30 -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=@oracle.com header.s=corp-2019-08-05 header.b="KKTeV+/j"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729654AbfIZIOj (ORCPT + 99 others); Thu, 26 Sep 2019 04:14:39 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:37126 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725883AbfIZIOi (ORCPT ); Thu, 26 Sep 2019 04:14:38 -0400 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x8Q8EMNj095953; Thu, 26 Sep 2019 08:14:35 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=date : from : to : cc : subject : message-id : mime-version : content-type; s=corp-2019-08-05; bh=YDRRpVAtUWoOxNUyo4YRN1dH81wF4V8OciFyOM/bsSc=; b=KKTeV+/j14MDSdEkpTJ/hZYSgcx0pcAf0UfV7cef+vW8nQfVg2di0XL69sZfOoRPtse5 Kh5DErxoBhAXXWUnwZZIWnLhaeGqg7WevuDWzOMTJsL0gy6YWIgGvgoX7GvJSU2d3wJE 2GQNzCGcy5B+DX4e/sdHW8QFOmshI27/7wqJ5j+4ZHXmQPubXV9AOkPH7GeVDyOtXJ7C Mquxjf2fp4sNUF9XUL5wNCpjWWkJT3V+U8P26Q2yBAh87SiCGQU05jkWHV0kNq5Nbcg7 SJmglC8HVYdsLMIkBHCrEqwMQ9pqU9zi5grHgLSutLhVfNMVdzgUhEAe2mORwLkS4T9Z og== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by aserp2120.oracle.com with ESMTP id 2v5btqa041-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 26 Sep 2019 08:14:35 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x8Q88fFR130879; Thu, 26 Sep 2019 08:14:35 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserp3030.oracle.com with ESMTP id 2v82tmp2ck-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 26 Sep 2019 08:14:34 +0000 Received: from abhmp0007.oracle.com (abhmp0007.oracle.com [141.146.116.13]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x8Q8EY9u022413; Thu, 26 Sep 2019 08:14:34 GMT Received: from mwanda (/41.57.98.10) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 26 Sep 2019 01:14:33 -0700 Date: Thu, 26 Sep 2019 11:14:26 +0300 From: Dan Carpenter To: Ray Jui , Yendapally Reddy Dhananjaya Reddy Cc: Scott Branden , bcm-kernel-feedback-list@broadcom.com, Linus Walleij , linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: [PATCH] ns2: Fix off by one bugs in ns2_pinmux_enable() Message-ID: <20190926081426.GB2332@mwanda> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Mailer: git-send-email haha only kidding User-Agent: Mutt/1.10.1 (2018-07-13) X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9391 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=955 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1908290000 definitions=main-1909260080 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9391 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1011 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1908290000 definitions=main-1909260081 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The pinctrl->functions[] array has pinctrl->num_functions elements and the pinctrl->groups[] array is the same way. These are set in ns2_pinmux_probe(). So the > comparisons should be >= so that we don't read one element beyond the end of the array. Fixes: b5aa1006e4a9 ("pinctrl: ns2: add pinmux driver support for Broadcom NS2 SoC") Signed-off-by: Dan Carpenter --- drivers/pinctrl/bcm/pinctrl-ns2-mux.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/pinctrl/bcm/pinctrl-ns2-mux.c b/drivers/pinctrl/bcm/pinctrl-ns2-mux.c index 2bf6af7df7d9..9fabc451550e 100644 --- a/drivers/pinctrl/bcm/pinctrl-ns2-mux.c +++ b/drivers/pinctrl/bcm/pinctrl-ns2-mux.c @@ -640,8 +640,8 @@ static int ns2_pinmux_enable(struct pinctrl_dev *pctrl_dev, const struct ns2_pin_function *func; const struct ns2_pin_group *grp; - if (grp_select > pinctrl->num_groups || - func_select > pinctrl->num_functions) + if (grp_select >= pinctrl->num_groups || + func_select >= pinctrl->num_functions) return -EINVAL; func = &pinctrl->functions[func_select]; -- 2.20.1