linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Dan Carpenter <dan.carpenter@oracle.com>,
	Scott Branden <scott.branden@broadcom.com>,
	Linus Walleij <linus.walleij@linaro.org>,
	Sasha Levin <sashal@kernel.org>,
	linux-gpio@vger.kernel.org
Subject: [PATCH AUTOSEL 4.14 07/24] pinctrl: ns2: Fix off by one bugs in ns2_pinmux_enable()
Date: Wed, 30 Oct 2019 11:55:38 -0400	[thread overview]
Message-ID: <20191030155555.10494-7-sashal@kernel.org> (raw)
In-Reply-To: <20191030155555.10494-1-sashal@kernel.org>

From: Dan Carpenter <dan.carpenter@oracle.com>

[ Upstream commit 39b65fbb813089e366b376bd8acc300b6fd646dc ]

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 <dan.carpenter@oracle.com>
Link: https://lore.kernel.org/r/20190926081426.GB2332@mwanda
Acked-by: Scott Branden <scott.branden@broadcom.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 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 4b5cf0e0f16e2..951090faa6a91 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


  parent reply	other threads:[~2019-10-30 15:56 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-30 15:55 [PATCH AUTOSEL 4.14 01/24] arm64: dts: Fix gpio to pinmux mapping Sasha Levin
2019-10-30 15:55 ` [PATCH AUTOSEL 4.14 02/24] regulator: ti-abb: Fix timeout in ti_abb_wait_txdone/ti_abb_clear_all_txdone Sasha Levin
2019-10-30 15:55 ` [PATCH AUTOSEL 4.14 03/24] regulator: pfuze100-regulator: Variable "val" in pfuze100_regulator_probe() could be uninitialized Sasha Levin
2019-10-30 15:55 ` [PATCH AUTOSEL 4.14 04/24] ASoC: wm_adsp: Don't generate kcontrols without READ flags Sasha Levin
2019-10-30 15:55 ` [PATCH AUTOSEL 4.14 05/24] ASoc: rockchip: i2s: Fix RPM imbalance Sasha Levin
2019-10-30 15:55 ` [PATCH AUTOSEL 4.14 06/24] ARM: dts: logicpd-torpedo-som: Remove twl_keypad Sasha Levin
2019-10-30 15:55 ` Sasha Levin [this message]
2019-10-30 15:55 ` [PATCH AUTOSEL 4.14 08/24] ARM: mm: fix alignment handler faults under memory pressure Sasha Levin
2019-10-30 15:55 ` [PATCH AUTOSEL 4.14 09/24] scsi: scsi_dh_alua: handle RTPG sense code correctly during state transitions Sasha Levin
2019-10-30 15:55 ` [PATCH AUTOSEL 4.14 10/24] scsi: sni_53c710: fix compilation error Sasha Levin
2019-10-30 15:55 ` [PATCH AUTOSEL 4.14 11/24] scsi: fix kconfig dependency warning related to 53C700_LE_ON_BE Sasha Levin
2019-10-30 15:55 ` [PATCH AUTOSEL 4.14 12/24] ARM: dts: imx7s: Correct GPT's ipg clock source Sasha Levin
2019-10-30 15:55 ` [PATCH AUTOSEL 4.14 13/24] perf c2c: Fix memory leak in build_cl_output() Sasha Levin
2019-10-30 15:55 ` [PATCH AUTOSEL 4.14 14/24] USB: legousbtower: fix a signedness bug in tower_probe() Sasha Levin
2019-10-30 15:55 ` [PATCH AUTOSEL 4.14 15/24] perf kmem: Fix memory leak in compact_gfp_flags() Sasha Levin
2019-10-30 15:55 ` [PATCH AUTOSEL 4.14 16/24] ARM: davinci: dm365: Fix McBSP dma_slave_map entry Sasha Levin
2019-10-30 15:55 ` [PATCH AUTOSEL 4.14 17/24] scsi: target: core: Do not overwrite CDB byte 1 Sasha Levin
2019-10-30 15:55 ` [PATCH AUTOSEL 4.14 18/24] ARM: 8926/1: v7m: remove register save to stack before svc Sasha Levin
2019-10-30 15:55 ` [PATCH AUTOSEL 4.14 19/24] of: unittest: fix memory leak in unittest_data_add Sasha Levin
2019-10-30 15:55 ` [PATCH AUTOSEL 4.14 20/24] MIPS: bmips: mark exception vectors as char arrays Sasha Levin
2019-10-30 15:55 ` [PATCH AUTOSEL 4.14 21/24] i2c: stm32f7: remove warning when compiling with W=1 Sasha Levin
2019-10-30 15:55 ` [PATCH AUTOSEL 4.14 22/24] cifs: Fix cifsInodeInfo lock_sem deadlock when reconnect occurs Sasha Levin
2019-10-30 15:55 ` [PATCH AUTOSEL 4.14 23/24] nbd: handle racing with error'ed out commands Sasha Levin
2019-10-30 15:55 ` [PATCH AUTOSEL 4.14 24/24] nbd: verify socket is supported during setup Sasha Levin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191030155555.10494-7-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=dan.carpenter@oracle.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=scott.branden@broadcom.com \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).