Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp738662img; Fri, 22 Mar 2019 07:35:21 -0700 (PDT) X-Google-Smtp-Source: APXvYqxQEnFLWwHpzYCxgxDrKoDjerEJ1SGQVGBR8A5+qlxg7jRiCTHCt0/rJ3Gw15ORDF0JU5st X-Received: by 2002:a17:902:b201:: with SMTP id t1mr10022259plr.55.1553265320941; Fri, 22 Mar 2019 07:35:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553265320; cv=none; d=google.com; s=arc-20160816; b=kz4p6CdftAFh17K/ba3jjmU5kcw9cWjz+B5rBspKSFKSPSEXH5o3/8yE1QSM5DgYpk gZBmBZIAWUXVszv8TrofjJ5USWc9gE31fSJr/fO1pkKkmWelEinnHTK3+wbXcZH+wrUV eOdchg44YIkC+iKUmtQNX/M8B+/vt4lWH3q3PpKqX77RIx6yPF24AY43asJhP1IEeD9g O6SubK+1zZrqdquyzrZM7sub6HFkjHJhmI4MHCEFtl6UI2hkhIaj3xxII5XIrU4P73l4 2IMJAxHb0fxGAnU0zEgwiqz4Uu6qWbEx3b1QNVTaJiM3I+/GB9SPTl1ZpCN7K1tPabmW UOnw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=WmZdDAMzQEc/pRiMl+70YVP0T4U9PhgqPYiVB01fqSQ=; b=fOd5K8l5ok3ZEhPblWg97smLXtO6G8KxgvTPafhR3oeKWn6xr0VovIDFerreWIfVAM iAohuRwoXxQRYiI6W1h/M1j9O16YuzrguHh94Ha7MRNRsQ6caGa+qHyL0tsLSb80w9eJ bFmheM3SK8q/+N7ABWWHRxg5rukQaPaqEM7+UZCsr0l1flTzlgsrQNElKNQopiHbhH5Y 2QkvcbUuZwjLlwFDni5KxCfa2v6+geSSG2GxKybbAkXWc2hfuTW7lVzIacYewlglVDlJ S3fg7JBa6CWRUS6+MZmmtv3+OvSsIJqkIhinGtgPUxIqi1ZGkU8xJOlxyWvWt8v30qB4 iJ2A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b4si6658174pgq.50.2019.03.22.07.35.05; Fri, 22 Mar 2019 07:35:20 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729084AbfCVOeZ (ORCPT + 99 others); Fri, 22 Mar 2019 10:34:25 -0400 Received: from mout.kundenserver.de ([212.227.126.133]:42545 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729067AbfCVOeY (ORCPT ); Fri, 22 Mar 2019 10:34:24 -0400 Received: from wuerfel.lan ([149.172.19.189]) by mrelayeu.kundenserver.de (mreue009 [212.227.15.129]) with ESMTPA (Nemesis) id 1MPXpS-1hL0DB0LKc-00Ma3I; Fri, 22 Mar 2019 15:33:47 +0100 From: Arnd Bergmann To: Lee Jones Cc: clang-built-linux@googlegroups.com, Nick Desaulniers , Nathan Chancellor , Arnd Bergmann , Charles Keepax , Linus Walleij , Sapthagiri Baratam , Colin Ian King , patches@opensource.cirrus.com, linux-kernel@vger.kernel.org Subject: [PATCH] mfd: arizona: fix undefined behavior Date: Fri, 22 Mar 2019 15:33:37 +0100 Message-Id: <20190322143345.1208144-1-arnd@arndb.de> X-Mailer: git-send-email 2.20.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-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b4r060nnA== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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.0