From patchwork Thu Jan 10 08:26:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chen-Yu Tsai X-Patchwork-Id: 10755301 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B6D9591E for ; Thu, 10 Jan 2019 08:27:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A590E29105 for ; Thu, 10 Jan 2019 08:27:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 98D2929108; Thu, 10 Jan 2019 08:27:00 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 3B28A29105 for ; Thu, 10 Jan 2019 08:27:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:To :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=GV6fymg5h4K4sRQwo8n0i+hxxJN9ROB6XdnZgkiGYUY=; b=fdfbwHyjYc5i2B 3emGvOvM4qmdN5fTTcX2pGoKD3iiuoL7h9cRIrcRvyRaUXU+rzgrprt1Vs3Gjct8JOvUuEn8RCWl7 kH7IqtBUgqK0kbceCZSpyO4Ml6BxWBt73O8p36DwTvNe2KaeysE4E7+P3dIWhlQiTdc+Ub4ypcx1l U+GgDSarVhrU5iE4XvzAFxtG6YWQOvDZrryR51Ok67DpmC2ZySdZHxq2NJ8OUsYkkcJwUiMiHyM0E jyShxBdvvngRLA8XR8Ht/9rgFRvmtzXOpRIVExOLlxJNdViCpt5lF9RYCvQfVXuBBI7mEaYLOPby4 DEVgmFV8NFGo3lUrgTww==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1ghVfz-0004Mo-NQ; Thu, 10 Jan 2019 08:26:55 +0000 Received: from mirror2.csie.ntu.edu.tw ([140.112.30.76] helo=wens.csie.org) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1ghVfg-00047N-WB for linux-arm-kernel@lists.infradead.org; Thu, 10 Jan 2019 08:26:39 +0000 Received: by wens.csie.org (Postfix, from userid 1000) id 160925FC23; Thu, 10 Jan 2019 16:26:34 +0800 (CST) From: Chen-Yu Tsai To: Maxime Ripard , Linus Walleij Subject: [PATCH 1/2] pinctrl: sunxi: Increase size of regulator array Date: Thu, 10 Jan 2019 16:26:32 +0800 Message-Id: <20190110082633.6321-1-wens@csie.org> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190110_002637_184250_BD6A6096 X-CRM114-Status: GOOD ( 13.70 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-gpio@vger.kernel.org, Chen-Yu Tsai , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP On the A80, the pin banks go up to PN, which translates to the 14th entry in the regulator array. The array is only 12 entries long, which causes the sunxi_pmx_{request,free} functions to access beyond the array on the A80 and the A31 (which has pin bank PM). While the accessed data is still valid allocated data within the same driver data structure, it is likely not a pointer. Increase the size of the regulator array from 12 to 14. This is a simple fix. While we could have the code take into account the fact that R_PIO pin banks start from PL, or maybe even dynamically allocate the array based on the last pin of the pin controller, the size reduction probably isn't worth the additional code complexity. Fixes: 9a2a566adb00 ("pinctrl: sunxi: Deal with per-bank regulators") Signed-off-by: Chen-Yu Tsai --- This fixes a crash due to an invalid pointer on the A80. --- drivers/pinctrl/sunxi/pinctrl-sunxi.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/pinctrl/sunxi/pinctrl-sunxi.h b/drivers/pinctrl/sunxi/pinctrl-sunxi.h index e340d2a24b44..e8161aa17dab 100644 --- a/drivers/pinctrl/sunxi/pinctrl-sunxi.h +++ b/drivers/pinctrl/sunxi/pinctrl-sunxi.h @@ -136,7 +136,7 @@ struct sunxi_pinctrl { struct gpio_chip *chip; const struct sunxi_pinctrl_desc *desc; struct device *dev; - struct sunxi_pinctrl_regulator regulators[12]; + struct sunxi_pinctrl_regulator regulators[14]; struct irq_domain *domain; struct sunxi_pinctrl_function *functions; unsigned nfunctions;