From patchwork Wed Nov 16 14:18:18 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 101519 Delivered-To: patch@linaro.org Received: by 10.140.97.165 with SMTP id m34csp179013qge; Wed, 16 Nov 2016 06:19:48 -0800 (PST) X-Received: by 10.98.198.85 with SMTP id m82mr4821238pfg.69.1479305988865; Wed, 16 Nov 2016 06:19:48 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m5si32104785pgj.182.2016.11.16.06.19.48; Wed, 16 Nov 2016 06:19:48 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-gpio-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-gpio-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-gpio-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751652AbcKPOTl (ORCPT + 4 others); Wed, 16 Nov 2016 09:19:41 -0500 Received: from mout.kundenserver.de ([212.227.17.13]:52246 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752810AbcKPOT0 (ORCPT ); Wed, 16 Nov 2016 09:19:26 -0500 Received: from wuerfel.lan ([78.43.21.235]) by mrelayeu.kundenserver.de (mreue101 [212.227.15.145]) with ESMTPA (Nemesis) id 0LsyHC-1cnO0E1EmQ-012cS5; Wed, 16 Nov 2016 15:18:52 +0100 From: Arnd Bergmann To: Linus Walleij Cc: Arnd Bergmann , Maxime Ripard , Chen-Yu Tsai , linux-gpio@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH] pinctrl: sunxi: fix theoretical uninitialized variable access Date: Wed, 16 Nov 2016 15:18:18 +0100 Message-Id: <20161116141841.2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bRQB5jEP8bl4gHuPrBZNAhcFNKXZuHoB7fb0LOEvDBvX6nkI3VhOzIuzHrFb1yt rbLx+2g Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org gcc warns about a way that it could use an uninitialized variable: drivers/pinctrl/sunxi/pinctrl-sunxi.c: In function 'sunxi_pinctrl_init': drivers/pinctrl/sunxi/pinctrl-sunxi.c:1191:8: error: 'best_div' may be used uninitialized in this function [-Werror=maybe-uninitialized] This cannot really happen except if 'freq' is UINT_MAX and 'clock' is zero, and both of these are forbidden. To shut up the warning anyway, this changes the logic to initialize the return code to the first divider value before looking at the others. Fixes: 7c926492d38a ("pinctrl: sunxi: Add support for interrupt debouncing") Signed-off-by: Arnd Bergmann --- drivers/pinctrl/sunxi/pinctrl-sunxi.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) -- 2.9.0 -- To unsubscribe from this list: send the line "unsubscribe linux-gpio" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/pinctrl/sunxi/pinctrl-sunxi.c b/drivers/pinctrl/sunxi/pinctrl-sunxi.c index 2339d4718b4d..6b7953da4228 100644 --- a/drivers/pinctrl/sunxi/pinctrl-sunxi.c +++ b/drivers/pinctrl/sunxi/pinctrl-sunxi.c @@ -1125,10 +1125,13 @@ static int sunxi_pinctrl_build_state(struct platform_device *pdev) static int sunxi_pinctrl_get_debounce_div(struct clk *clk, int freq, int *diff) { unsigned long clock = clk_get_rate(clk); - unsigned int best_diff = ~0, best_div; + unsigned int best_diff, best_div; int i; - for (i = 0; i < 8; i++) { + best_diff = abs(freq - clock); + best_div = 0; + + for (i = 1; i < 8; i++) { int cur_diff = abs(freq - (clock >> i)); if (cur_diff < best_diff) {