From patchwork Wed Aug 23 14:39:27 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 9917491 X-Patchwork-Delegate: sboyd@codeaurora.org Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 641FB60327 for ; Wed, 23 Aug 2017 14:40:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 56D1928932 for ; Wed, 23 Aug 2017 14:40:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4B497289AF; Wed, 23 Aug 2017 14:40:39 +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=-6.4 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DF7AB28932 for ; Wed, 23 Aug 2017 14:40:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932100AbdHWOk1 (ORCPT ); Wed, 23 Aug 2017 10:40:27 -0400 Received: from mout.kundenserver.de ([212.227.126.134]:50081 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754053AbdHWOkY (ORCPT ); Wed, 23 Aug 2017 10:40:24 -0400 Received: from wuerfel.lan ([95.208.190.237]) by mrelayeu.kundenserver.de (mreue003 [212.227.15.129]) with ESMTPA (Nemesis) id 0Lvfyq-1dTzSj0XpU-017XWD; Wed, 23 Aug 2017 16:39:41 +0200 From: Arnd Bergmann To: =?UTF-8?q?Emilio=20L=C3=B3pez?= , Michael Turquette , Stephen Boyd , Maxime Ripard , Chen-Yu Tsai Cc: Arnd Bergmann , linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH] clk: sunxi: fix uninitialized access Date: Wed, 23 Aug 2017 16:39:27 +0200 Message-Id: <20170823143937.2176025-1-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 X-Provags-ID: V03:K0:Bp6luNvKPXxKi2RNhZm4GqWD6Kj0MvSgYiu8inPEbvkgYxNx4F7 EO3KKBuPeiG4xviZz9CoVvVSGX9+EjJMIpRa2cjSc2ThpLn2sme7GOhR8p/fi5l0RvSoi1N p0/3tFbj/8r22ggP9EjOFZV8cbZo80Qadi+w4HXOKYL+zZPq9rhylnHZKaF1YpUkwhwF4o2 r8ga29/cc46vbcqWBiiGA== X-UI-Out-Filterresults: notjunk:1; V01:K0:9hiMxjkyy9o=:c8h6PjN5oiKte4DQarxmbP iV6ddt/6qa9W2hmrKPqUx1nHG/pZDObOfoFSxxV34QR26ZWOTp/vwSndT9F1XptTeGBd1ymHI RNn83/41fgPMhZ+0+eXZxDgZu+JtBQt42f22sL5WZvWZFemf2lTwfcSnmuy6C3DvI/0ZO3kSO NaBn3k7UOktf6uuPKDig2NhTyOtaJFFeeObq/FtnxLJHGye4WFYsYMGytJOUEBEFFcD3yes31 8nYJW08JF3FNgO90hGgNTTQklfxt+OOtYhgYgO0yDqfxHb8bi643aOtJTXR8bntw/yDaK/lmy 4d+lslxSzth01LgYLuaEOBHKD0m8cyWq5O7QTygRghYbZcJggf9bLzxnQd6T2q8tS+TQjDlg4 4elcxD1owB4reroGgCZtbc39lGIiVr0a4IYhbg22ulPkIbJHys1x4NoYtGLMwwNbvErZLf+cw 3WiQrtB9l8qc4aY5fLPOC4bZM+J/rZu5d0vHvo9bhPMlYjrqa68fxH3SsuGrXPESjLDLQPplc P9J3V+7efMi3fjBRxpFAt62rNpFZ4i7eFzvZsa09aVIlPZAxBZ5NuDzGDxaHJkATwz81AqHg5 VGZCOT1j/Wm+xUKJ0YEexDwMZE0XJyz8TUOp7g6f5AynRrhZsPS5bfWuep9JOm5BDGk9buJbb izB800Jhj3yoqkaFL3D8GGMN+nO1t7mhcEP4Yz8pr4jovTtXpWOL5DIHY80cprj6XsKEDlVXF dk7FGonTl0spJgu4sVy1CFUtE3mUjeM+RNSarw== Sender: linux-clk-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-clk@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP gcc-8 reports an uninitialized variable access in a code path that we would see with incorrect DTB input: drivers/clk/sunxi/clk-sun8i-bus-gates.c: In function 'sun8i_h3_bus_gates_init': drivers/clk/sunxi/clk-sun8i-bus-gates.c:85:27: error: 'clk_parent' may be used uninitialized in this function [-Werror=maybe-uninitialized] This works around by skipping invalid input and printing a warning instead if it ever happens. The problem was apparently part of the initiali driver submission, but older compilers don't notice it. Fixes: ab6e23a4e388 ("clk: sunxi: Add H3 clocks support") Signed-off-by: Arnd Bergmann Acked-by: Maxime Ripard --- drivers/clk/sunxi/clk-sun8i-bus-gates.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/clk/sunxi/clk-sun8i-bus-gates.c b/drivers/clk/sunxi/clk-sun8i-bus-gates.c index 63fdb790df29..bee305bdddbe 100644 --- a/drivers/clk/sunxi/clk-sun8i-bus-gates.c +++ b/drivers/clk/sunxi/clk-sun8i-bus-gates.c @@ -78,6 +78,10 @@ static void __init sun8i_h3_bus_gates_init(struct device_node *node) clk_parent = APB1; else if (index >= 96 && index <= 127) clk_parent = APB2; + else { + WARN_ON(true); + continue; + } clk_reg = reg + 4 * (index / 32); clk_bit = index % 32;