Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp1203959ybi; Fri, 2 Aug 2019 11:05:27 -0700 (PDT) X-Google-Smtp-Source: APXvYqxD3SanjQ0L+rMrQicqD4j1jN3LtdtW5J983HAZeIYlptrCg7q6ZBzuNFAVz3ynHY0CH9L7 X-Received: by 2002:a62:1a8e:: with SMTP id a136mr60099763pfa.22.1564769127410; Fri, 02 Aug 2019 11:05:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564769127; cv=none; d=google.com; s=arc-20160816; b=DLfaPCGWYlgbepwZyJFQwBPgwCwhZ+HDyZgF/T48QdFwTgUpXw8iwwxrvpuRkjileP ZNLpBNlSHTXspdexwkO4eAzXvo1/OPFZS0uljAefU85msHNoMwYKOUjBcAPVOaKoLfxw YRBYjTx5c4BX3Rvci2VOoL/k5V5hDMncq4furrZdiK6uPN5VYa+s5qAwow+s5uXKXnau toblomTdThVRMhCNcoiSjro28VoQIwLyHzy4jSxbF+PWugIQ14koofHzawnegD38JBF9 hHapd5MxEkmBOuZMbrRfr3z9kO856/HW1EPR/kDoItEmk1xDisG6lWUFfUoKY4h+NuQd 1dzQ== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=/KP4U4xkCfYN1cu2EcG5UdhA7pc4/WmxQmwBRE5eOfk=; b=nL6cpQe8b1CPI8T9C3ptn/OkopVz+QPObYgyp4Udtx2760yIY4zJkG/PpuZJWRA68V Rhpw+wSF99wgD5pXFDim7b3YcfurHooL/fC1brrFUBA221+BVZMgpVdNwT9ExSZGhOcW KXrLW8Fwwf+srrLKWMmuvsCMiTdvg6bprMx5+HZnFp7WC+QLDpJdXDC+d4OzC6QT7do3 twBdNsQZbyanM7asV/6+Ay3t1NFbj2MOoukGsq68GD9UFNds2KlUZj5csIwoPRXirXCL cTI5JkUaYwenTN9vUTq74YyQXTMWZ1xMuDuKFRiSMxz5xnwGjViBgfpfV9l9+MKVohRH a/nA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=tXyM61CL; 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 g8si34431620plt.273.2019.08.02.11.05.02; Fri, 02 Aug 2019 11:05:27 -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; dkim=pass header.i=@kernel.org header.s=default header.b=tXyM61CL; 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 S2392126AbfHBJv5 (ORCPT + 99 others); Fri, 2 Aug 2019 05:51:57 -0400 Received: from mail.kernel.org ([198.145.29.99]:57286 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2392043AbfHBJv4 (ORCPT ); Fri, 2 Aug 2019 05:51:56 -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 18CAB2064A; Fri, 2 Aug 2019 09:51:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564739515; bh=PvcT+3ynpcSEWsklJgvIPEQZHgA+Nk4rLOp4AnKgNJk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tXyM61CLPxDLbnPAMei8vu85qTjjcfUIiYGGOwSpNlIgqLBMa4n6nFso1kvfq0dlI VnHnWUJWgtxr2K1I8wfNiUGN90ZP0NokPe32959O6D5PpxgpG6e4S2XN4PQCMeAYZB FvmG50vlNkQnrLc8thz2DhKmgza3Eg/ibEvpgp78= 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.9 182/223] mfd: arizona: Fix undefined behavior Date: Fri, 2 Aug 2019 11:36:47 +0200 Message-Id: <20190802092249.427081370@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190802092238.692035242@linuxfoundation.org> References: <20190802092238.692035242@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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 41767f7239bb..0556a9749dbe 100644 --- a/drivers/mfd/arizona-core.c +++ b/drivers/mfd/arizona-core.c @@ -1038,7 +1038,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