Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3110302ybi; Thu, 18 Jul 2019 21:13:21 -0700 (PDT) X-Google-Smtp-Source: APXvYqxwxS7GsvQmOOe9l9oxOMC2uZeGsmJOyjvfK52zgk2RbugewFtXASZVmNPlb7m5EgBAG7y7 X-Received: by 2002:a63:e70f:: with SMTP id b15mr51922893pgi.152.1563509601527; Thu, 18 Jul 2019 21:13:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563509601; cv=none; d=google.com; s=arc-20160816; b=onWMbls0aaeueHoCVYVg8uPYCyanGBaaByEzidrdyxURLQK6eMuGnp7X2+jg2/kP+W LWLw6Cm1Oejz3d1ulAaaycHOdMWmq0P207hlOlki5euaxj6CaJMv/QqUDpD921wRB/kL 8L7nAewWhDFf37FvutT8L2Cpc36q3w2RFCkiyfe1By6GyPbwsyF+ei72GcxyFD7885Rs mmK/P5cRSsTIhoOsLo2g1M8DocjY7j4xeKKFvBlEHHH/sFETPNe/hrZ4GmFiKExDjgpu PLgHGvPAk1a+IsxHDkthVZF7w90zZyK8SufvthnQrfupUi6Trw24Htmonm5/Pb+deGXT MDaQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=n5aWtca6yBHzKp2Nw8CuQR5vNU4TsDITwAE1MUV3unE=; b=HEYEfDG4K0uS4YxT5BOKZpM+IU/snsGGEYf4fFC/YDsJ5V/nWe5CMt8Nw0pEDNbggX 5sBzgJHsbYLHo+oqJVv1bkobb3qcOcDO/yyS81jMOFVMLosDoqR/1FW4C05srRLHABv6 vT2t9uai9xF7b74AZj/r0mkyU0Mu/2GrQ50RI0ZiscCcKNSZwgJ+vPc96gWS158+tKCt Xu1Ch8ivhLKh/voT/ex17YAPRVO0IABQXCV5fEGtwA8eBFyGcaaxvEMY/IYBlrCWT0ga tKBkYOMLxbv0uGpUqjrZM94jwS/Vi9UCZEkfpvHp7czclASSCAdVxql+QrJZYFl5kxUx Ir6Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=SoYYt8OR; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h12si484707pjq.63.2019.07.18.21.13.06; Thu, 18 Jul 2019 21:13:21 -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=SoYYt8OR; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388730AbfGSEMO (ORCPT + 99 others); Fri, 19 Jul 2019 00:12:14 -0400 Received: from mail.kernel.org ([198.145.29.99]:47444 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388715AbfGSEMM (ORCPT ); Fri, 19 Jul 2019 00:12:12 -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 564C92189D; Fri, 19 Jul 2019 04:12:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1563509531; bh=1x8+kDSeNkVT9tcWmYSucD9gjeBRRQa2aItkVOo4UO0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SoYYt8ORefO/IVSPC2w/bVGgLMZa+Jck70FB6oJqFw0qx2PnzgDXjDnnadKnrx5ou RlK4mkT1UBpDaeU6/ISCnuI3TcrGMmy6Cr+wxfJD+mmoWwFRsIAsBGKLlJ+d3XKVEc TB2uU1alN9ApE9bwIXNIa+w+TsKC0NBJvOpkOWUU= 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 4.14 34/60] mfd: arizona: Fix undefined behavior Date: Fri, 19 Jul 2019 00:10:43 -0400 Message-Id: <20190719041109.18262-34-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190719041109.18262-1-sashal@kernel.org> References: <20190719041109.18262-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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 8d46e3ad9529..d8e3184bd27c 100644 --- a/drivers/mfd/arizona-core.c +++ b/drivers/mfd/arizona-core.c @@ -1029,7 +1029,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