From patchwork Mon May 20 09:06:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Charles Keepax X-Patchwork-Id: 164575 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp35795ili; Mon, 20 May 2019 02:06:44 -0700 (PDT) X-Google-Smtp-Source: APXvYqyCp/tt6tRIMZvLhANvgUXadEFXfAQEKDl7uFCvvWAaAj6Z4iJrMBXoG/RFHdpjEXOPEk+O X-Received: by 2002:a63:3:: with SMTP id 3mr73241330pga.360.1558343204138; Mon, 20 May 2019 02:06:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558343204; cv=none; d=google.com; s=arc-20160816; b=AT9oZosnsq1MdU4fQ6TghgL1mRcdwOWyCG1Cz6YVcepwdk2rPawQRL3XHk1G3J2qxk N5FUO+wzginejHfjilNBANNG8s6uA48fkNk5cmXwBjq+uYjTfqxaamUUKs5hiqI7BLRI WHFcNa6Ij1LwPOY8+ZGLxnGBHehBysxrgfE9Nt5H95CRi35/OeNLGsPsKE/ci77xH/1K pf/Y7m21zMESNy7afud037eNnhNaf4Jc5QFugWI4HZEWN7EEUj0yZ1JeKltntgzdLcdV iX8JASdyJOLGoi4RnZ0kChGs7ZYFu/q/IO4wWtjhAWt/5zmILf3FPv/cCB17KCVk62iq GzQw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from; bh=6ExCo8kZpI1oHvNOP5IL5x9QNEv/zomTqubLMg8qVGM=; b=x85uNrGGX03HseTbp26wLt0xlGDjRkliLrfwp5U1m3tCotr/I3/cfJeWcGLpiI8Co5 c9LfHrb8t1X4sr3tVcT40T6XSnMVX/Vh+Qw+p1MjFOj/YWeNRZe8j7z8N9xPsw04bce+ C3ZYwNzLY0L4W/9R9oaPuVLkBxxxeG20yoynSfvqOMIkpu4xET3F/na9EHthyPeEbt6H kkTPKPydbP9N0s/NBOgMLe9me8i4jB3h3Z0GBANvAWaykLE8pPVU8BzLp+bjhFenwCSY 9hyarE4dWJYmSogkXdPowkPFHyTg+YF36MB943iP1txY4UwnJ5aucYa5lnah1MIdvMTY uqHg== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=opensource.cirrus.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u6si17152197pgr.12.2019.05.20.02.06.43; Mon, 20 May 2019 02:06:44 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=opensource.cirrus.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731815AbfETJGm (ORCPT + 30 others); Mon, 20 May 2019 05:06:42 -0400 Received: from mx0b-001ae601.pphosted.com ([67.231.152.168]:45412 "EHLO mx0b-001ae601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730512AbfETJGl (ORCPT ); Mon, 20 May 2019 05:06:41 -0400 Received: from pps.filterd (m0077474.ppops.net [127.0.0.1]) by mx0b-001ae601.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x4K93oKF011611; Mon, 20 May 2019 04:06:30 -0500 Authentication-Results: ppops.net; spf=none smtp.mailfrom=ckeepax@opensource.cirrus.com Received: from mail1.cirrus.com (mail1.cirrus.com [141.131.3.20]) by mx0b-001ae601.pphosted.com with ESMTP id 2sjefmt40y-1; Mon, 20 May 2019 04:06:29 -0500 Received: from EDIEX02.ad.cirrus.com (unknown [198.61.84.81]) by mail1.cirrus.com (Postfix) with ESMTP id 92B0C611C8B9; Mon, 20 May 2019 04:06:29 -0500 (CDT) Received: from EDIEX01.ad.cirrus.com (198.61.84.80) by EDIEX02.ad.cirrus.com (198.61.84.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1591.10; Mon, 20 May 2019 10:06:28 +0100 Received: from ediswmail.ad.cirrus.com (198.61.86.93) by EDIEX01.ad.cirrus.com (198.61.84.80) with Microsoft SMTP Server id 15.1.1591.10 via Frontend Transport; Mon, 20 May 2019 10:06:28 +0100 Received: from algalon.ad.cirrus.com (algalon.ad.cirrus.com [198.90.251.122]) by ediswmail.ad.cirrus.com (Postfix) with ESMTP id 90D7745; Mon, 20 May 2019 10:06:28 +0100 (BST) From: Charles Keepax To: CC: , , , , Subject: [PATCH 1/4 RESEND] mfd: arizona: fix undefined behavior Date: Mon, 20 May 2019 10:06:25 +0100 Message-ID: <20190520090628.29061-1-ckeepax@opensource.cirrus.com> X-Mailer: git-send-email 2.11.0 MIME-Version: 1.0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=927 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1905200066 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Arnd Bergmann 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 --- drivers/mfd/arizona-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.11.0 Reviewed-by: Mauro Carvalho Chehab diff --git a/drivers/mfd/arizona-core.c b/drivers/mfd/arizona-core.c index 27b61639cdc7e..0ca0fc9a67fd9 100644 --- a/drivers/mfd/arizona-core.c +++ b/drivers/mfd/arizona-core.c @@ -996,7 +996,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);