Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3816052ybi; Mon, 29 Jul 2019 13:10:51 -0700 (PDT) X-Google-Smtp-Source: APXvYqwjoDhdBgxJPOEpxmWzPESb9gej1lHrtwacxbYTSScKTM/iFIpyNLtD3cypVBpXjQn7wCje X-Received: by 2002:a63:e14d:: with SMTP id h13mr106013051pgk.431.1564431051065; Mon, 29 Jul 2019 13:10:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564431051; cv=none; d=google.com; s=arc-20160816; b=lBhlnHceeKqTPVs7im8YdAC+0rRPSez2xLs6dtWcxYVEQxI7ntE/lrP9Mxn9CzwyWU MnOAGINCqRklhCW6gqyvkAbUZDnZQsYCOC1UJrQtpwMgB5XyYziwwxCdD6R1NbASyKGJ ec+x0F+yzi4dQIYXDJIM9rgKpbBvl65rAapj5/+KkueUONZ6Zddmlht/CIao1vrtnih5 OFkUBLCLPBKyF9/Bp/+q7EAbQKNHMTu0TqJZuQ86fdYRnfXyws+1lPt023FL0aefg8Yc LaE1s2rNCh4adte9PgS4eflJ+L1JRv5FxapIH6usBf9ito2m3Wl6d+xnQ233PyfHvlDB +e9w== 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=5bSwePnTZwCheNz8Vtuz/HLaDezLR79ZvhBpqL5fiRY=; b=tetAkcPwzqQjXChHKkwb5S/kkBNzI5joclUOG9n4b9uAD7Vwrcde0UDSgaVHDN+HtH al95ue79oJR3bjgOrSWnjEGuyUTfYVcQSBJiR4qkTt5vKXySRTBxoT+PRJF+i7u9Ic3y l9/oecLrmY1osL0+LUF0s1G4qt5XiVFpPQyv2+ys3iVMtDBnyrXl+mhRgS1hckiQ2WJu uM1zASbyswuE/vaEI/8Tpf28AXYk1XmulM557u7BJFJZJL/qzcrUU6PTKDVrOemc0HJo 6fO7w7OnBQe/rTSpewWK268wqcS5Pj6JK2E5Idyza7qixjiZR8ZtmoIfJIeolRX6r6Ru UHBg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=FrUMcvaE; 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 66si27598987pld.6.2019.07.29.13.10.35; Mon, 29 Jul 2019 13:10:51 -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=FrUMcvaE; 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 S1730039AbfG2Tgm (ORCPT + 99 others); Mon, 29 Jul 2019 15:36:42 -0400 Received: from mail.kernel.org ([198.145.29.99]:51052 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729979AbfG2Tgj (ORCPT ); Mon, 29 Jul 2019 15:36:39 -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 B23EF2171F; Mon, 29 Jul 2019 19:36:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564428998; bh=04jNJTUnxhY6tAhzQlVsvBcjeNpy9XKRWG+kmZ+tne8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FrUMcvaE0Q28K2ROQtz6AmQ+jOLJHldU0StWdnhRBKNB26c0mpX5/AfFb0kIJwWa6 5Q1u0pr4vMapQcr0R8ETZRTs+lSmDFN25WFez2BDgHJxinOc44EA8LxElAQhUVRvx7 1wU17qNMv5kfFtJbJzadpz5bJoVSm5Idu83ZbacY= 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.14 252/293] mfd: arizona: Fix undefined behavior Date: Mon, 29 Jul 2019 21:22:23 +0200 Message-Id: <20190729190843.749583106@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190729190820.321094988@linuxfoundation.org> References: <20190729190820.321094988@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 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