From mboxrd@z Thu Jan 1 00:00:00 1970 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D9B3EC98321 for ; Thu, 24 Sep 2026 20:12:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Type:MIME-Version: References:In-Reply-To:Subject:Cc:To:From:Message-ID:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=1l+fgLLAyjMgURCtvH8zvJd7xRcHgmJBh+kC4m+jdwg=; b=C6/59thInun/fccU2y5Q9VvVGJ rhocMmlydanqQ6DEGY2vT8gmX6kO9WxRl9iITC0LdH51+lCyFAorDxMU2dtE7RqJmZsSsTURK7UGG UrXn3NhXiqIngDmas+SedpMU5ubxCllM4PhBNv4opReNxNhh5GRtKIHVc9lvr0ithArINDXK+KIPE WhDJeMrmEnQ/HPhii8ewHQdS7G+ckPEOXCGcYRM/TtQcYuGxv8P81ZtA8F5aMt17VojszNrT03rZj 7ATmvmNJv6fc4GSSaZfJOVWw3DNTca1ZHK81Yc3kHnmLKpR24TN3gQL3MzFCP5ostUBxm3h/Kr4sZ CWCWGXAQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.99.1 #2 (Red Hat Linux)) id 1x9poE-0000000C7Qn-3zJg; Thu, 24 Sep 2026 20:12:46 +0000 Received: from tor.source.kernel.org ([172.105.4.254]) by bombadil.infradead.org with esmtps (Exim 4.99.1 #2 (Red Hat Linux)) id 1x9po8-0000000C7PO-33xm for linux-arm-kernel@lists.infradead.org; Thu, 24 Sep 2026 20:12:40 +0000 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by tor.source.kernel.org (Postfix) with ESMTP id 27532601DE; Thu, 24 Sep 2026 20:12:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D11CC1F000FF; Thu, 24 Sep 2026 20:12:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1790280759; bh=1l+fgLLAyjMgURCtvH8zvJd7xRcHgmJBh+kC4m+jdwg=; h=Date:From:To:Cc:Subject:In-Reply-To:References; b=dfGGI8k/bZFsyZMVeEHNjSDZwV0FD00DT+Y3Hd40cLANmjHqnhmM8tqkjla84nik2 BUeVc/nx4cAilX6vPa5Rdh+OauhtiItTjn13gKj4FGnMMv3z8Xi/gLalkNBYFOdlOb jnBog84X4IalE5OCUQctwTOzbvRhUZfMjSrMU6mFlcyr/ZSHe64dhwGi7aGUJ+bMlX ME0YVa7RfOn4nQl+MZkw00bdnuT88GcRLZ3t8Yl13x2YiocpA7j5uPQGMzoe3vgN83 jadi50BIAdcVv9gTaBqJ2j02aej9HbcwvtecXOpJFuepq5k4Ue5M64RMFWME8zX2wa lw22Kk2XlLSfw== Received: from sofa.misterjones.org ([185.219.108.64] helo=goblin-girl.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1x9po5-0000000DCkz-21I3; Thu, 24 Sep 2026 20:12:37 +0000 Date: Thu, 24 Sep 2026 21:12:36 +0100 Message-ID: <86jyoa4de3.wl-maz@kernel.org> From: Marc Zyngier To: Yuho Choi , Jonathan Cameron Cc: Thomas Gleixner , Lorenzo Pieralisi , Radu Rendec , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v1] irqchip/gic-v3-its: Drop ITS node reference on its_of_probe() errors In-Reply-To: <20260923101026.000034ea@oss.qualcomm.com> References: <20260923165447.619477-1-oss.patchbox@gmail.com> <20260923101026.000034ea@oss.qualcomm.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/30.1 (aarch64-unknown-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: oss.patchbox@gmail.com, jonathan.cameron@oss.qualcomm.com, tglx@kernel.org, lpieralisi@kernel.org, radu@rendec.net, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Wed, 23 Sep 2026 18:10:26 +0100, Jonathan Cameron wrote: > > On Wed, 23 Sep 2026 12:54:40 -0400 > Yuho Choi wrote: > > > its_of_probe() walks the ITS nodes with of_find_matching_node(), which > > drops the reference on the previous node and returns the next one with > > its reference count raised. The loops are balanced when they run to the > > end, but the three error returns (a failed its_reset_one(), a failed > > its_node_init() and a failed its_probe_one()) leave with the current > > node still referenced. > > > > Drop it before returning. > > > > Fixes: c733ebb7cb67 ("irqchip/gic-v3-its: Reset each ITS's BASERn register before probe") > > Fixes: 9585a495ac93 ("irqchip/gic-v3-its: Split allocation from initialisation of its_node") > > Signed-off-by: Yuho Choi > > I only took a very quick look but why can't this use for_each_matching_node() > > That doesn't solve your problem but it would be easy to add a for_each_matching_node_scoped() > in similar spirit to for_each_child_of_node_scoped() I think and that would give you a cleaner fix here. +1. It'd be much better to have an infrastructure for this sort of things. Otherwise, the obvious way to do this locally would be as below, instead of the proposed sprinkling of direct of_node_put(). Completely untested, as usual. M. diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c index e9807af235373..91e08b5229b1c 100644 --- a/drivers/irqchip/irq-gic-v3-its.c +++ b/drivers/irqchip/irq-gic-v3-its.c @@ -5561,7 +5561,6 @@ static void its_node_destroy(struct its_node *its) static int __init its_of_probe(struct device_node *node) { - struct device_node *np; struct resource res; int err; @@ -5571,7 +5570,7 @@ static int __init its_of_probe(struct device_node *node) * reset, don't even try to go any further, as this could * result in something even worse. */ - for (np = of_find_matching_node(node, its_device_id); np; + for (struct device_node *np __free(device_node) = of_find_matching_node(node, its_device_id); np; np = of_find_matching_node(np, its_device_id)) { if (!of_device_is_available(np) || !of_property_read_bool(np, "msi-controller") || @@ -5583,7 +5582,7 @@ static int __init its_of_probe(struct device_node *node) return err; } - for (np = of_find_matching_node(node, its_device_id); np; + for (struct device_node *np __free(device_node) = of_find_matching_node(node, its_device_id); np; np = of_find_matching_node(np, its_device_id)) { struct its_node *its; -- Without deviation from the norm, progress is not possible.