From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id DD692EB64DA for ; Wed, 12 Jul 2023 17:20:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:Message-Id:MIME-Version:Subject: Date:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=BFcnd6cio4ZtEr8oXbiXD2WZ0BAnNDIumweCJ/xm9Y0=; b=CsfKoxLmS68yYp fgc3t9jVHaMWWFlXEYQ6xSt/A5+GiCwhFYEKpHIYSr3hxDeC/MgFAQs9sT4l4RC2+jnR2qfZoHudd S+rA6GgpTAoHoUHnO7Jp+GexVDGyUWcR6crHAiuOZbvqW60hf0U1ZYtAl3TkgmV0+wXz8FW3IFQRU mMmCi3oIzyWEU6AgKC6O3YKoUcjVQ8/iIKj/EypS2Dj8Fafq/Mr6bkY14PtvHyyIDnpD3hOs7LrQ+ JlhGXgIlpXLTBsCqAGlzsQ1LmkVtfI0xI9GLvaJQU9oMvvadD+XlCr+OK2zy1jGxXFtbgDXcui98c +paSq5B9zRdXueiKKggw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qJdVl-000jeW-1S; Wed, 12 Jul 2023 17:20:21 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qJdVi-000jdv-24 for linux-arm-kernel@lists.infradead.org; Wed, 12 Jul 2023 17:20:19 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 26A4361879; Wed, 12 Jul 2023 17:20:18 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C1086C433C8; Wed, 12 Jul 2023 17:20:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1689182417; bh=3gPj2OLmTQiKQXAQaSmLuzHQbyixVTI9hSntm0pe89c=; h=From:Date:Subject:To:Cc:From; b=S/8oTBEQaVAolENbbe7Jf9UDWVskfQYIgG38pt/JjHUBsc5xLqN2jhbv2YJrJGuXL zHII+fYTNpd5+9TSUEdAJqt132sxqFvOyLhwPfsg5NK0oEU+D9MGjIjqWLak7Bo7LO +6/qU084uj6npi5eDboG6VpB214VFUxHHjQfkt0ZFfSZ0jprWmvFi22Zgk8vkxmSXJ apghrB6KVousvQl/aAxNU4sWQH7U0BunuKUqchg5nOofTCBQR/mi83z0DweuG33Ip4 XUIcGBPV+HLTLzk+H+Cvxtvnm+JRHp1KEsAgK/M1hfFV/D9PCir67wEhCi02Sc6Bcj 27Gvi5xX71cnQ== From: Mark Brown Date: Wed, 12 Jul 2023 18:19:59 +0100 Subject: [PATCH] pinctrl: sunxi: Add some defensiveness for regulators array MIME-Version: 1.0 Message-Id: <20230712-pinctrl-sunxi-boudns-v1-1-85f37de79b9f@kernel.org> X-B4-Tracking: v=1; b=H4sIAL7grmQC/x3MMQqAMAxA0atIZgOtUopeRRzURg1IlEZFkN7d4 viG/19QikwKbfFCpJuVd8mwZQHTOshCyCEbKlPVxluLB8t0xg31kodx3K8gio0bZxeGOhjvIKd HpJmff9v1KX06IFsyZgAAAA== To: Linus Walleij , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland Cc: linux-gpio@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org, Mark Brown X-Mailer: b4 0.13-dev-099c9 X-Developer-Signature: v=1; a=openpgp-sha256; l=1234; i=broonie@kernel.org; h=from:subject:message-id; bh=3gPj2OLmTQiKQXAQaSmLuzHQbyixVTI9hSntm0pe89c=; b=owEBbQGS/pANAwAKASTWi3JdVIfQAcsmYgBkruDOruL4nOFfNlPL6CqLv3/eOKtVcuXRUpj+b72M ISUrRpuJATMEAAEKAB0WIQSt5miqZ1cYtZ/in+ok1otyXVSH0AUCZK7gzgAKCRAk1otyXVSH0L4jB/ wMyfEW/O45XvRvUxKZxYqTo73x4AuL9rRWlESg7ixOG3fYoEUmsKI5eW3zmfmxl0w/dxt1Tf7LjcRm MJBOrT9UKa4Eqcgqt8muv27avkgpnx7ZOTAJHGAu4XQ78cx7xafEYrESk3AL4rRj0D397nVhUXkclQ YLPyvKUxjAeOOcSjZV8721BIdc9YbQmqVqXE8odc/Qx6n5rS2ill0LfVibKAliubIarNjTN3fQIN16 ZNedeTo17S2IMEBEz40VAnfmqVlQtLrcYrdJcHfk6Of1Sk+zvrpCXzFNGqVDz6/Rc1yKUSLwx8Gd8l COLL69wcEODbn5HsDoh72IpGkaq6y4 X-Developer-Key: i=broonie@kernel.org; a=openpgp; fpr=3F2568AAC26998F9E813A1C5C3F436CA30F5D8EB X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230712_102018_724532_BBF0E195 X-CRM114-Status: GOOD ( 13.47 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The sunxi pinctrl has a fixed size array it uses to store regulators used in the driver. There is currently nothing that ensures that the number of elements in the array is large enough to map the regulators defined by the individual SoCs. While this is currently the case having an explicit check in there will make life easier for anyone debugging memory issues that manifest in the driver so let's add one. Signed-off-by: Mark Brown --- drivers/pinctrl/sunxi/pinctrl-sunxi.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/pinctrl/sunxi/pinctrl-sunxi.c b/drivers/pinctrl/sunxi/pinctrl-sunxi.c index 1dc1882cbdd7..1d1cd3d6d379 100644 --- a/drivers/pinctrl/sunxi/pinctrl-sunxi.c +++ b/drivers/pinctrl/sunxi/pinctrl-sunxi.c @@ -848,6 +848,9 @@ static int sunxi_pmx_request(struct pinctrl_dev *pctldev, unsigned offset) char supply[16]; int ret; + if (WARN_ON_ONCE(bank_offset >= ARRAY_SIZE(pctl->regulators))) + return -EINVAL; + if (reg) { refcount_inc(&s_reg->refcount); return 0; --- base-commit: 06c2afb862f9da8dc5efa4b6076a0e48c3fbaaa5 change-id: 20230711-pinctrl-sunxi-boudns-95bf5da3d075 Best regards, -- Mark Brown _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel