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=-9.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham 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 A5A6AC32750 for ; Fri, 2 Aug 2019 09:35:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 801B6217D4 for ; Fri, 2 Aug 2019 09:35:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564738514; bh=0OpYPO3EC8jV+NiEo+d+SuUqsyNfIjARhZUpikUmzNE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=2aGosns4tb9Xw4pwQ1wvjxwa9GRuVF+jj9H+uxSNYNVCJ/6tU4F0BJbiCiZSsrkbP 4vb5tPgnXMD3aK8OPB3NzKCp9HcRtwUMOanFTqKtmua0lmz8umRHAcUm0TCnkhe6fe OqMQavuh+3NldPvVTy1oLbjlWmkHBDwheHoJbkLs= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389610AbfHBJfN (ORCPT ); Fri, 2 Aug 2019 05:35:13 -0400 Received: from mail.kernel.org ([198.145.29.99]:35504 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391616AbfHBJfK (ORCPT ); Fri, 2 Aug 2019 05:35:10 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 8FE49217D7; Fri, 2 Aug 2019 09:35:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564738510; bh=0OpYPO3EC8jV+NiEo+d+SuUqsyNfIjARhZUpikUmzNE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RbZvADUz2P0DxnDFcrd50ZeeoBmGAa/quSd8i3JicHQg00RR0XlzuThmyHexOaYlx IlCjw60pBq9dBMgC83xbphengiseZoTgRp1GaBjS/Q+127UcUN4CX3dmVFxGyR1svU bvHRZQ4j6/bWCqxTPau9zo5QBYLRmQrUFeoXaspE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Arnd Bergmann , Nathan Chancellor , Charles Keepax , Lee Jones , Sasha Levin Subject: [PATCH 4.4 124/158] mfd: arizona: Fix undefined behavior Date: Fri, 2 Aug 2019 11:29:05 +0200 Message-Id: <20190802092228.914367465@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190802092203.671944552@linuxfoundation.org> References: <20190802092203.671944552@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org [ 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 d474732cc65c..fb54de5c1aba 100644 --- a/drivers/mfd/arizona-core.c +++ b/drivers/mfd/arizona-core.c @@ -967,7 +967,7 @@ int arizona_dev_init(struct arizona *arizona) unsigned int reg, val, mask; 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