From nobody Sun Feb 8 15:53:19 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CF2EFC77B7F for ; Tue, 16 May 2023 10:31:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232271AbjEPKbG (ORCPT ); Tue, 16 May 2023 06:31:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57992 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231240AbjEPKa7 (ORCPT ); Tue, 16 May 2023 06:30:59 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 528472115 for ; Tue, 16 May 2023 03:30:58 -0700 (PDT) Date: Tue, 16 May 2023 10:30:56 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1684233057; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=j+c4JJvREZ+ry2RQubPPKenPgjrnm6wLOyGS5iUdMgo=; b=bwiMbxzSgmU2lgHkMNmeHLuU1yQScs7FBt6pYsZhRQw1IMnlb9l8WchPVu41OKvfNZXyrW XHzMwb48UOLCG6yuWZJPuUmrsc+Dg9ifuiLg2gRoCXqarUwblPTph/CBNN04eYtpOgwi/2 G5jDQ74rpcUMat6+f3PioQT1l5zL5J3baz2FqBPmSmzhttLII7tRxZup+RU63nqkVRcmQU 3BI8lyisaJdlElp51oQp8zYr/TTi26wHsY/WEemLonjbTEMaYk8S0MeWmCP65vyVn17chS b+NOccYvvLR09jHL9nvwEfQtVqyrj+mVhUxiH1MD/cjrXXisSjwui0+S+nMfnw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1684233057; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=j+c4JJvREZ+ry2RQubPPKenPgjrnm6wLOyGS5iUdMgo=; b=qc6g+YDGLGlOJbCk23czPQUcrFOHYqvhXe9Zz4i9Md/cioobFqTEy0nWHaF939jNb4rJcc lWgWfoqa5qe6QQBA== From: "irqchip-bot for Kefeng Wang" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-kernel@vger.kernel.org Subject: [irqchip: irq/irqchip-fixes] irqchip/mbigen: Unify the error handling in mbigen_of_create_domain() Cc: Dan Carpenter , Kefeng Wang , Marc Zyngier , tglx@linutronix.de In-Reply-To: <20230505090654.12793-1-wangkefeng.wang@huawei.com> References: <20230505090654.12793-1-wangkefeng.wang@huawei.com> MIME-Version: 1.0 Message-ID: <168423305640.404.14948493018092002475.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the irq/irqchip-fixes branch of i= rqchip: Commit-ID: cddb536a73ef2c82ce04059dc61c65e85a355561 Gitweb: https://git.kernel.org/pub/scm/linux/kernel/git/maz/arm-plat= forms/cddb536a73ef2c82ce04059dc61c65e85a355561 Author: Kefeng Wang AuthorDate: Fri, 05 May 2023 17:06:54 +08:00 Committer: Marc Zyngier CommitterDate: Tue, 16 May 2023 11:19:29 +01:00 irqchip/mbigen: Unify the error handling in mbigen_of_create_domain() Dan Carpenter reported that commit fea087fc291b "irqchip/mbigen: move to use bus_get_dev_root()" leads to the following Smatch static checker warning: drivers/irqchip/irq-mbigen.c:258 mbigen_of_create_domain() error: potentially dereferencing uninitialized 'child'. It should not cause a problem on real hardware, but better to fix the warning, let's move the bus_get_dev_root() out of the loop, and unify the error handling to silence it. Reported-by: Dan Carpenter Signed-off-by: Kefeng Wang Signed-off-by: Marc Zyngier Link: https://lore.kernel.org/r/20230505090654.12793-1-wangkefeng.wang@huaw= ei.com --- drivers/irqchip/irq-mbigen.c | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/drivers/irqchip/irq-mbigen.c b/drivers/irqchip/irq-mbigen.c index eada5e0..5101a3f 100644 --- a/drivers/irqchip/irq-mbigen.c +++ b/drivers/irqchip/irq-mbigen.c @@ -240,26 +240,27 @@ static int mbigen_of_create_domain(struct platform_de= vice *pdev, struct irq_domain *domain; struct device_node *np; u32 num_pins; + int ret =3D 0; + + parent =3D bus_get_dev_root(&platform_bus_type); + if (!parent) + return -ENODEV; =20 for_each_child_of_node(pdev->dev.of_node, np) { if (!of_property_read_bool(np, "interrupt-controller")) continue; =20 - parent =3D bus_get_dev_root(&platform_bus_type); - if (parent) { - child =3D of_platform_device_create(np, NULL, parent); - put_device(parent); - if (!child) { - of_node_put(np); - return -ENOMEM; - } + child =3D of_platform_device_create(np, NULL, parent); + if (!child) { + ret =3D -ENOMEM; + break; } =20 if (of_property_read_u32(child->dev.of_node, "num-pins", &num_pins) < 0) { dev_err(&pdev->dev, "No num-pins property\n"); - of_node_put(np); - return -EINVAL; + ret =3D -EINVAL; + break; } =20 domain =3D platform_msi_create_device_domain(&child->dev, num_pins, @@ -267,12 +268,16 @@ static int mbigen_of_create_domain(struct platform_de= vice *pdev, &mbigen_domain_ops, mgn_chip); if (!domain) { - of_node_put(np); - return -ENOMEM; + ret =3D -ENOMEM; + break; } } =20 - return 0; + put_device(parent); + if (ret) + of_node_put(np); + + return ret; } =20 #ifdef CONFIG_ACPI