Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3799028ybi; Mon, 29 Jul 2019 12:51:29 -0700 (PDT) X-Google-Smtp-Source: APXvYqxOEXJClG7IFJyJU4UcrR9maviDw5W680FybMjSMfvWCGVGHy7pKsrzbuIpJbN4/jAipLSS X-Received: by 2002:a17:90a:8d86:: with SMTP id d6mr113063660pjo.94.1564429889543; Mon, 29 Jul 2019 12:51:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564429889; cv=none; d=google.com; s=arc-20160816; b=PGHs1zp6Cl0cqts4Yfg+ZUBnmk+IW+n8X7e1oOcT7JvgA5DBUdtWojX+IX6ocxIGxB F5nZML0uQ1JND7TZVJjUKbS96QcFnW0t58+bup6HOaqDfY/9BovsGyVlJiHjh+H8oImt /41s4c8DoVo3eux0Orbcu/PutbCq04LCCPPhush96lgbLtXl+O8fhvJ/XapTDCtbckCh thhYXWlElWUrRE+QKWNwkE1Oy99CuuC+NEJe0G77pbf5XQ2JS4mNNxn6Brpt+BYIPJUb 2kKicrgz+rUSbaYIseGofwhQd/4lJ//1GH2TinpD8zJ4W7RmJQ0E1IO6DwPhc0t7kuBN zHzg== 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=fVkyf/pbjNdBtADA5r3OPKE3mPGTAMVG73xMXMuHP3A=; b=RR6qOpLQcrQFu8ihPQaVS/eYpVOC2f/RGL3kvUx+yI6wdLel5XXQXECkb3kNSlE6u9 lzup7Ug+z7uOrE4q3dS4A2iHjbfmY5Fn5BQfRZk3PYpXQcSNFdZis7wIsnZTDiq4IdP8 c3Oz803QCVyqI9epM6KSQIcZQF8Z8XV6obcYYLs/tq/sWhI+ouuh/si62GLLdEhXjtQE j0UFrPXHtshA01BxwkFqpwDksQfvYxu7qAMYG4RxA3s8mgZVjKjjDBY3zNFc9Td3Akcv oRA9Jkt89pdE+QD+ZifsBr8H5r5i1MxU+UZix/1TXnMf6TWV86mSP2UjMeWdHxmOINX8 ++Fg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=BBLHiude; 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 d30si26041666pla.419.2019.07.29.12.51.14; Mon, 29 Jul 2019 12:51:29 -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=BBLHiude; 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 S2390581AbfG2Tt6 (ORCPT + 99 others); Mon, 29 Jul 2019 15:49:58 -0400 Received: from mail.kernel.org ([198.145.29.99]:40714 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389663AbfG2Tt4 (ORCPT ); Mon, 29 Jul 2019 15:49: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 54E8B20C01; Mon, 29 Jul 2019 19:49:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1564429795; bh=kjuaKcVGdZLMeE8ERw3n4NKhFt9rShF2NZW0HGOJWz4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=BBLHiudezv/EgbmzqQGuqHeLp3YpHeUk69y3qZavn0ixr/et8MdIOX6qXvXRa+ErD L/0RrDEpt0p//hgQPa66t7w+NBQv2dA6Edm4vz6c7mB+eQ6VeOulKTzIfBVfp+I8ll 4Kc+p+xfZtoaLecemqmUpm6zIovvvhiStqrqZmZY= 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 5.2 098/215] mfd: arizona: Fix undefined behavior Date: Mon, 29 Jul 2019 21:21:34 +0200 Message-Id: <20190729190756.134390941@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190729190739.971253303@linuxfoundation.org> References: <20190729190739.971253303@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 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