From patchwork Tue Nov 3 21:29:06 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 3841 Return-Path: X-Original-To: noreply@patchwork.local Delivered-To: noreply@patchwork.local Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) by mxe881.netcup.net (Postfix) with ESMTPS id 970611C7289 for ; Tue, 3 Nov 2026 22:33:30 +0100 (CET) Authentication-Results: mxe881; dkim=pass header.d=kernel.org; spf=pass (sender IP is 172.234.253.10) smtp.mailfrom=linux-sunxi+bounces-27145-noreply=patchwork.local@lists.linux.dev smtp.helo=sea.lore.kernel.org Received-SPF: pass (mxe881: domain of lists.linux.dev designates 172.234.253.10 as permitted sender) client-ip=172.234.253.10; envelope-from=linux-sunxi+bounces-27145-noreply=patchwork.local@lists.linux.dev; helo=sea.lore.kernel.org; Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sea.lore.kernel.org (Postfix) with ESMTP id 395122C95C for ; Tue, 3 Nov 2026 21:30:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1793741419; b=mCy2L5BC/yEnJ0kM/DtdW2prCaqtjOZ3CAvQZB499QUxJ/U6kjjvoOW3vJnGx/I32xCC NXlD1N+PArPOZgSNQ3OEv2el3hpycoZtgS67+EFhexBRHaAyz4FjwhjxLWdhYcR+Auqep yEbPg6vuYh3sghO5Ln4SS/kmL+63hNsLN0RnmQsgq1KBFO2mB1CVMoLq3AsMk/J4bjT9p T7yK2uluoYi/nfUBopc9e/xu5YUlXcNIRzY04Qpp5s2CF3wYrNG39Wprnf4SGjlevi0ZQ UNznU+c+4gD+vVpIgAsTZqzYq7UzrTqEe7b9DfSq2nSDQjy1PqCIHeqq4p41Cqa9nfg== ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793741419; h=X-Original-To:Received:Received:DKIM-Signature:From:To:Cc:Subject: Date:Message-ID:X-Mailer:In-Reply-To:References:X-Mailing-List: List-Id:List-Post:List-Help:List-Subscribe:List-Unsubscribe: List-Owner:Precedence:MIME-Version:Content-Transfer-Encoding; bh=kZJOzDauoYNsrCoO2C6W6zBNYUEYiaq0/P1CBtElekI=; b=2zlzAN3GGhhLC2einTiJ9fY2oSe3dOJjhZ2lSHZxNk5rhkbutmrsQrpa0MEYhKOcIHSs e1BeX2xsRfmRa89FIZCGaqI21rzelu5C6H39qF34AjS9WNtrEa/TUwsUCAGyAzpA7Z01c dFdhbPOM58ciD+1bIlfVlJa/8enbMz+QSo8N11RXcjLl/d9xBqP3gViy/IsItfHJArFMt iMBxmZ2BhZlNWgX8pMQVkN8WPqalbn7qF82jBjPLDtNjfKhy/MTcy8ERg7fmp8i7w7WdL dNdpZuFZzn92KAmYVo1dsNAQWOm8fJfWLVu5yXw2TD/efxCuRZP/UQXhMBCd512gszA== ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=bQ8Q9hrR; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0F4A1606A335; Tue, 3 Nov 2026 21:30:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=bQ8Q9hrR X-Original-To: linux-sunxi@lists.linux.dev Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1793741419; b=FitmXqA8WNAEZuA2XVB1bt8da66nZTbVxMKHoeOA7FqR/UH1qTsWoyOQsmEvGmNdaWWT UaSDCpMzhfZu6rCOIu8wMf7qGCNrdI8mLgX08yjnw99VigxQgzfLzkdWdTXwgcC6ANd51 x6A90p8QKzH+yeRjiZ7VxRN/QrBIFKrxiI4NsbN83MazSYbEJJ+/fwJfz6D1e6umk2paf QaytXaypwW6S2so+gCc2jrPg1Mpaa7EJMJMcRZucxKp8qcC4HbDkekPqSREuPUrcR5JoY m5mjkJRmsnLfcU+7qC80grsJ9+t3pFbCRtjh8btC+9XEb4tIn9O1MdsF4Z5Mmez4k/Q== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793741419; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:MIME-Version:Content-Transfer-Encoding; bh=kZJOzDauoYNsrCoO2C6W6zBNYUEYiaq0/P1CBtElekI=; b=4QCNJySHL9f5SkzFpl1OvMCGyY4d5zCJYJN7O2NaGXf/+UX/wW+5ZGyls/Y3nC/VMkHL 64vw1K+PcHyBWUPL3Z1AQFajSh+6rb/O16GGos599dj811cEBZKF/djr1DzLcj6PiTaKV sRxbNf6n5adNTR5d9EAW4mq6P2ZmFa7xtmx/Jd/qbfExXKQ5mi1VXQ/vs3fDUEWz4BL+7 IkGanRaTFmkA2DuulaI9ZWG6TM4G1py3Dg0gbgspWHIHbv1mkfRDwM6ErAyGV4Z+fx63h 8mH3O4yKZTr9pX9pP8/DZkttn4WOW+3a2AjN/BV3MaG9QYUL+Xg+YRi72urcSbbfCow== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=bQ8Q9hrR; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A53DC606A31B; Tue, 3 Nov 2026 21:30:18 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 77FC81F0093A; Tue, 3 Nov 2026 21:30:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1793741418; bh=kZJOzDauoYNsrCoO2C6W6zBNYUEYiaq0/P1CBtElekI=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=bQ8Q9hrRaX2ZAyUrBkbdXkItU0fTwhigtPiEd0fl3vtgaLJIHDV1VWPDO2EDF5dc+ qraDrCHe0JNj7ciU/cFBPoD5DecNQNvAFypvugugEcN51bbsbZLW7U71aFoilT4B6O KjZNjeLByf/Ag3dgbyQqv55nPkRPfaf1wXew/qa6lR+7qAKbbr/QJl0g+wNDdvRa9S PvsgJ9bjTc99hnkvc8BNwxdpBaNvihY35sUAR8dcVvixUT00hoRnKZseExGjVAPcG0 LgyWTuhyzFCKyLLedu33lEJNjV5H5poU5Dg31qfVd35cwC3Pq3ZiYnETuHRXBWTdjV X/tYsE8cO+U5w== From: Lee Jones To: lee@kernel.org, Linus Walleij , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Andre Przywara , linux-gpio@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org Cc: stable@vger.kernel.org Subject: [PATCH 01/10] pinctrl: sunxi: Fix out-of-bounds irq_bank index when first bank has no IRQs Date: Tue, 3 Nov 2026 21:29:06 +0000 Message-ID: <20261103213002.1673560-2-lee@kernel.org> X-Mailer: git-send-email 2.56.0.385.gac671c819a-goog In-Reply-To: <20261103213002.1673560-1-lee@kernel.org> References: <20261103213002.1673560-1-lee@kernel.org> X-Mailing-List: linux-sunxi@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 X-MORS-Enabled: yes X-MORS-DOMAIN: patchwork.local X-MORS-HOSTING: hosting172546 X-MORS-USER: hosting172546 X-getmail-retrieved-from-mailbox: INBOX In prepare_function_table(), irq_bank and last_bank are initialised to 0 and last_bank is updated on every bank regardless of whether it supports interrupts. On SoCs where bank 0 (PA) has no pins or does not support interrupts (such as Allwinner A523 and A733), the first IRQ-capable bank has bank > 0, which causes irq_bank to be incremented to 1 instead of starting at 0. As a result, the final IRQ bank receives irq_bank equal to desc->irq_banks and writes out-of-bounds past pctl->irq_array during sunxi_pinctrl_build_state(). Initialise irq_bank and last_bank to -1 and only update last_bank when processing an IRQ-capable bank so that irq_bank always starts at 0 and increments sequentially across IRQ-capable banks. Fixes: f5e2cd34b12f ("pinctrl: sunxi: allow reading mux values from DT") Closes: https://sashiko.dev/#/bug/linux-9c4dd832-02d4-4096-9e91-a03c1d4d85b3 Cc: stable@vger.kernel.org Signed-off-by: Lee Jones --- drivers/pinctrl/sunxi/pinctrl-sunxi-dt.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/drivers/pinctrl/sunxi/pinctrl-sunxi-dt.c b/drivers/pinctrl/sunxi/pinctrl-sunxi-dt.c index 8bcd566593ae..79ca1a7c4837 100644 --- a/drivers/pinctrl/sunxi/pinctrl-sunxi-dt.c +++ b/drivers/pinctrl/sunxi/pinctrl-sunxi-dt.c @@ -208,8 +208,8 @@ static int prepare_function_table(struct device *dev, struct device_node *pnode, * Assign the function's memory and fill in GPIOs, IRQ and a sentinel. * The extra functions will be filled in later. */ - irq_bank = 0; - last_bank = 0; + irq_bank = -1; + last_bank = -1; for (i = 0; i < npins; i++) { struct sunxi_desc_pin *pin = &pins[i]; int bank = (pin->pin.number - pin_base) / PINS_PER_BANK; @@ -222,17 +222,16 @@ static int prepare_function_table(struct device *dev, struct device_node *pnode, func[1].muxval = 1; if (irq_mux) { - if (bank > last_bank) + if (bank > last_bank) { irq_bank++; + last_bank = bank; + } func[lastfunc].muxval = irq_mux; func[lastfunc].irqbank = irq_bank; func[lastfunc].irqnum = pin->pin.number % PINS_PER_BANK; func[lastfunc].name = "irq"; } - if (bank > last_bank) - last_bank = bank; - pin->functions = func; /* Skip over the other needed functions and the sentinel. */