From patchwork Fri Mar 22 14:33:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 160909 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp885317jan; Fri, 22 Mar 2019 07:34:26 -0700 (PDT) X-Google-Smtp-Source: APXvYqwWbdMKouf8nPQI5CwFtcndLfyWHjGuWL/I7UdA1uhmVtllAFt/HGuasTMD03Zkko9/4zWH X-Received: by 2002:a63:66c4:: with SMTP id a187mr8619858pgc.369.1553265266470; Fri, 22 Mar 2019 07:34:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553265266; cv=none; d=google.com; s=arc-20160816; b=ly0D9lbq6kVYMYYbRLGPJOXMT2ilHY+EgTnGpOEtTqHi801UFKWHxX25SWF+gRLJo3 8yFU7mPFiu9YRBKkXJxqb2xKSo+FI88maEe9EB+MvjVGI/rWItO2vuRicyaCePFFByss hAigMN/Qe9+KpEMNgLYCJSSRJWkR5FdQGxdh1RXqZms00l4lrHSeQgkQdqqov9pm56q4 2UcwdFDIvhTdQUUJyDl2nWpHtnhRgsjf+wCMoqGYZon6WPvIs8y9iLVeMK4wSAMA3KNv ecQWzAJ7Z6+vi5bXSdNnToAfPKFv84ewD4s33CDIHH8w38Die/8kG57IXzwZHMzcrXMy Qyzw== 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 e67si7699691plb.107.2019.03.22.07.34.26; Fri, 22 Mar 2019 07:34:26 -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 S1729093AbfCVOeZ (ORCPT + 31 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 X-Provags-ID: V03:K1:xIa628kaEnjxRdbZtVTepxGCiZqr9F/xHj3Bl6rG4r9O/ufNc3k rfcAqo4uT3Q0sl+2SvhyhUf7rimuKFJa+zasw/NYhG/yVWAkF4hEAMbQCaT111cEB7eL/U+ tXxl/zfWba0aeClXAkNk/6oq3LdL7jGRSe6ltKI16+nZ59l8dOHQIGbDtKcI8rMNAAe1Y2R 4vib9SaiQnxLEMXJtT8IQ== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1; V03:K0:PzEbtT9jSxA=:NxTZ9ZfLS8xWvzxLZ82av0 sGiY7Yn/Ry7ePxEXa/CfUZp9rGnkJZyTV39wjYwQHCTwPubzfC+fig/ZkMfEqLzj5OjIK614s 0Fw0I7eYK5L+g5wLMecGTKyPEibq+62iK2ing2VZI+45fnBoHV81lG7OPjIwHgJfkIKVl3h6F tD8el8YYbooMlYdalnHvVwZc8u3XDP63XwRawIR3UyWFWR0MydchCXJIOdnGLL05oPKBxj6zs 1HMYliN0pHleHYv7XqHIeEW9bvZ7W8iZsVNDOjHYnaSDQqJyJYwejYfOm8Db9ND7rJbAk8akH vCQpt+xSIxAAnJJviM619ii/kMHNl1ruGYBL2wYXSxvAQEutTm1IgvC9VuASfi+JycFHJQ+OB q2YVugI15K/JeZ8SM77EUBdufhnmfRriehI/zl7GMFqXtv9MlQw+apv9EDFUwXs4ZXxk25FIJ 1F/BgoEvlfEk6n+XfDq9VU48IpU2kTMkCDCE/DEVQY5iXw/PcoW5lzuPx3OOa0lGoT33w9bj7 G4s51Dc+emTYHGlF0u2Ur3dOIFkqJR43Dkj+Am160aKzDnMFBE8EiPoc/X4tVwtOgp7h8N7T3 6wez0KVKmRNGVR7z6UyZvqMfxyXpHhnwYosf2UK8keicJPO46NEpb6OTlV9w1JidVTBE3sKVb 1/yHGwBNw9nJ/lIjAUZOvGdHE+pPPLWT3eVuioH2ZqN0YfudbOSgDJV4/ubj3HKv8Jh0neDRE WaO6Go6KMamAPLugWT8/1qw4ZrUeIb4r060nnA== 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(-) -- 2.20.0 Reviewed-by: Nathan Chancellor Acked-by: Charles Keepax 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);