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 X-Spam-Level: X-Spam-Status: No, score=-10.1 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 541CEC76195 for ; Fri, 19 Jul 2019 04:30:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 288C82082E for ; Fri, 19 Jul 2019 04:30:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1563510628; bh=D9A9AGZPv+SbNcPGaM52XE5WsIS1Akk6wosFa+eVrWc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=EISlGoN53Cl5TkEB2RB804QwFh9Ru8X/qsebWr/zgiVcu1pOApangLpxgQW/NwK0+ LVmEpGmRXX2gcaWbIpXh8vsheFM4OYfzTTC/Zila6lOepI4iRPrkSdHfzsUUaWLRot jyjtrlrMJdSgSByXcMCE0ECCF0J2VKVY+/5oASfM= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732167AbfGSEaX (ORCPT ); Fri, 19 Jul 2019 00:30:23 -0400 Received: from mail.kernel.org ([198.145.29.99]:37510 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731488AbfGSEFN (ORCPT ); Fri, 19 Jul 2019 00:05:13 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id D71B4218BA; Fri, 19 Jul 2019 04:05:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1563509112; bh=D9A9AGZPv+SbNcPGaM52XE5WsIS1Akk6wosFa+eVrWc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xo1XOysIKGSwSL577DbANuGM5m9vbJpgnle4BlmMnIxCoDtzgJ+xcbgZ53YJDW/Do KghU00PjrwLr6osqsjdITsY7oUCq8M5qUg6gqdpLMbjn0vq7fj5/WiRYiaHgjthMNZ DliRNqoV1PhRnY5DE9tTcfe1LnZL6gC8xz4FITac= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Arnd Bergmann , Nathan Chancellor , Charles Keepax , Lee Jones , Sasha Levin , patches@opensource.cirrus.com, clang-built-linux@googlegroups.com Subject: [PATCH AUTOSEL 5.1 076/141] mfd: arizona: Fix undefined behavior Date: Fri, 19 Jul 2019 00:01:41 -0400 Message-Id: <20190719040246.15945-76-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190719040246.15945-1-sashal@kernel.org> References: <20190719040246.15945-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Arnd Bergmann [ Upstream commit 5da6cbcd2f395981aa9bfc571ace99f1c786c985 ] When the driver is used with a subdevice that is disabled in the kernel configuration, clang gets a little confused about the control flow and fails to notice that n_subdevs is only uninitialized when subdevs is NULL, and we check for that, leading to a false-positive warning: drivers/mfd/arizona-core.c:1423:19: error: variable 'n_subdevs' is uninitialized when used here [-Werror,-Wuninitialized] subdevs, n_subdevs, NULL, 0, NULL); ^~~~~~~~~ drivers/mfd/arizona-core.c:999:15: note: initialize the variable 'n_subdevs' to silence this warning int n_subdevs, ret, i; ^ = 0 Ideally, we would rearrange the code to avoid all those early initializations and have an explicit exit in each disabled case, but it's much easier to chicken out and add one more initialization here to shut up the warning. Signed-off-by: Arnd Bergmann Reviewed-by: Nathan Chancellor Signed-off-by: Charles Keepax Signed-off-by: Lee Jones Signed-off-by: Sasha Levin --- drivers/mfd/arizona-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/mfd/arizona-core.c b/drivers/mfd/arizona-core.c index 27b61639cdc7..0ca0fc9a67fd 100644 --- a/drivers/mfd/arizona-core.c +++ b/drivers/mfd/arizona-core.c @@ -996,7 +996,7 @@ int arizona_dev_init(struct arizona *arizona) unsigned int reg, val; int (*apply_patch)(struct arizona *) = NULL; const struct mfd_cell *subdevs = NULL; - int n_subdevs, ret, i; + int n_subdevs = 0, ret, i; dev_set_drvdata(arizona->dev, arizona); mutex_init(&arizona->clk_lock); -- 2.20.1