Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3131305ybi; Thu, 18 Jul 2019 21:38:25 -0700 (PDT) X-Google-Smtp-Source: APXvYqwm7282gbmNHAJSQUrXTjHAwAfHgizcN40A/ZEU7DWYnNViRwiadABHHI6Du5vlKhdOZ/1L X-Received: by 2002:a17:90a:ba94:: with SMTP id t20mr55363262pjr.8.1563511105436; Thu, 18 Jul 2019 21:38:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563511105; cv=none; d=google.com; s=arc-20160816; b=YkpbEtU1Cn0duwYo01LUBWbyrjJcu7Zv9LBtfBPxDGCZj8MQaOSXbQRNI6TUbNRMQw Wyns0GiS0MuCYEXbvYXhlFTc3LSFjo6OFudxqJjlzWDmPITAjCiKgamFawo4LILwfFbI TvblHy2FLk5RJ9WMxTlsv5e2PA+mcDn3z0cc5H43dx4dod0bCA+zPaVLHOt/SI5ds2hz AKg8ABzwoOa/I68fu+2IRZObCABorngo89zd02oUhUyGOEdMqjjVRBaGeZo4LjI7etrL 5+N1mUj27b7EYCD8UhAnMeeUYYv5ZBFxocXG4wa1KAukNnpZSaudGm9XbQIXAtvLSge8 Y6Hg== 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=ZMGE/oSXhrnDCl/RHCuvzz56xe1jVVUBXE9KBl9dNWc=; b=Eg705w8V+T8g1vG0vc720DQPQbmwTymclN8En8NvORcU2bBdBvVHF9aTHxh9UVFHHJ 0PZ2e9Z1K7WOe/hj2SN72uuKd7DKyAAXRAtvbQQofLA/11rRATWi2KGdG3zI0RbOhih1 FBsJxI+2brlv3crRHXpCGL4BkcpYh5E2oo8oEgUnRytB6L1j1inllB1udH3kSexJbgsL V3yxEMcrqcXtR/+Jf7s80NTmdpNtdDz4hOn/oKaKkPV/Y14hF0YBfOgKd+crf5E71MPL QlQrs5yQWOePWCTpgY/aV38asjwzlgKtBE8zUonMWnEV4gtaLmgIqV+uIZdPOl75lVKX e6cg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="s6Gp/uNl"; 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 ba9si1041179plb.308.2019.07.18.21.38.10; Thu, 18 Jul 2019 21:38:25 -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="s6Gp/uNl"; 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 S1727480AbfGSEAM (ORCPT + 99 others); Fri, 19 Jul 2019 00:00:12 -0400 Received: from mail.kernel.org ([198.145.29.99]:59982 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726720AbfGSEAG (ORCPT ); Fri, 19 Jul 2019 00:00:06 -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 EFCA32189E; Fri, 19 Jul 2019 04:00:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1563508805; bh=n/H9DtgbR6PnQvash2wSB/L+kMnJ+lz8di/8qoW6B0g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=s6Gp/uNlGTBOz0vNCAGctlPyrSRH8TkpIrBhP8ugSTAmRBcThVRvefsueJvTiWk4t CP1Y1yK6cBxxn7T/3DaLp7Tex+s5t6Cw+dhddntvC4h88ZtfdkkMLPHrU5ZyBEGbZd BlYmRhb+1QI7nTZ6GnVgeYrUkD3BxRqX03UUUnPA= 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 5.2 100/171] mfd: arizona: Fix undefined behavior Date: Thu, 18 Jul 2019 23:55:31 -0400 Message-Id: <20190719035643.14300-100-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190719035643.14300-1-sashal@kernel.org> References: <20190719035643.14300-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 2bdc7b02157a..4a31907a4525 100644 --- a/drivers/mfd/arizona-core.c +++ b/drivers/mfd/arizona-core.c @@ -993,7 +993,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.1