From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4AD6F606A31C for ; Wed, 11 Nov 2026 09:16:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=gdAev9Ha; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=P7A1TJfi 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-Unsubscribe-Post:List-Owner; bh=/kxyqAjTx8NKkvcCIqcp+hxivFQPr/EPfwfGlYdXLBo=; b=gdAev9HaLWYJKPvNVU0fa9I1OB 7ICcQRyweq0tHJgHDpuRxB2ZnWEA0SFnz+ohsm8YlVhFq+Ismh+KpCQnM0zKpX+0oeVqFm5V6IL6q 8XMnOiqiGTPH6WgjYz8Ocs8OLvbAS3onnfY30gVHKo9vzbCvvD1TSJEIh616E/sdLC0daK6cOK2of QRE/9MoAupOjmZBDcWo/KBX2U9T0hE44ZvZbjcESBxCYWUHAuRTNcRLtzqs5oj1bEwT720Gb6bRzx BcWOxYzMhQuPUVsmAHk+460R0Cv4KXzW6Q9WI1gpNxVcLKz7NFXydkpRjbFEG9kCxc6fGxobsHjzA ov2UNAgA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.100.1 #2 (Red Hat Linux)) id 1xR4RS-000000068m0-0yIY; Wed, 11 Nov 2026 09:16:30 +0000 Received: from sea.source.kernel.org ([2600:3c0a:e001:78e:0:1991:8:25]) by bombadil.infradead.org with esmtps (Exim 4.100.1 #2 (Red Hat Linux)) id 1xR4RR-000000068lo-1TjN for linux-arm-kernel@lists.infradead.org; Wed, 11 Nov 2026 09:16:29 +0000 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by sea.source.kernel.org (Postfix) with ESMTP id B703A411F9; Wed, 11 Nov 2026 09:16:28 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9938C1F00A05; Wed, 11 Nov 2026 09:16:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1794388588; bh=/kxyqAjTx8NKkvcCIqcp+hxivFQPr/EPfwfGlYdXLBo=; h=Date:From:To:Cc:Subject:In-Reply-To:References; b=P7A1TJfiZg5LGMcrmNqWFXtnGzfzl8JlB4qhPmCkPJlDbx8GzwX2BXfFhJi56MwTW WByErjjad9MmnJuLPDh3pHLeEyaRZluGONi4TamiQorHBlHA7p+1uUSXsLKvq/iSLR 9AZClhvcAFsuEU5NS8Vf6mPRLFU1WHlh+vofS+o+s9viRNQsg8207ziHMVp+ldVP/2 4vHLS22uyAyuy4Y4H1hNUCd0V7oDMPEdEOy9q8qPX2YGpCn7VOLIPoB/1wMc5eaBL7 O4kQf5RdXfTED7Pq5b1g+NAhyxlgSS1RaQ4qwCTuAgZC9j0lKbmmdnfR6MLq5b/zVS o0x4MnDlC24ng== 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 1xR4RO-0000000ECsx-1jVW; Wed, 11 Nov 2026 09:16:26 +0000 Date: Wed, 11 Nov 2026 09:16:26 +0000 Message-ID: <86qzgr20et.wl-maz@kernel.org> From: Marc Zyngier To: Yuho Choi Cc: Thomas Gleixner , Jonathan Cameron , Lorenzo Pieralisi , Radu Rendec , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] irqchip/gic-v3-its: Drop ITS node reference on its_of_probe() errors In-Reply-To: <20261103201817.1259660-2-oss.patchbox@gmail.com> References: <20261103201817.1259660-2-oss.patchbox@gmail.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) X-Archived-By: 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, tglx@kernel.org, jonathan.cameron@oss.qualcomm.com, 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-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" X-Spam-Status: No, score=-15.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 On Tue, 03 Nov 2026 20:18:10 +0000, 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. > > Declare the iterator in each loop with __free(device_node), so that the > reference is dropped whichever way the loop is left. > > 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") > Suggested-by: Marc Zyngier > Signed-off-by: Yuho Choi > --- > v2: > - Use __free(device_node) on the loop iterators instead of adding > of_node_put() to each error return (Marc). > - Rebased on v7.4-rc1. > > v1: https://lore.kernel.org/r/20260923165447.619477-1-oss.patchbox@gmail.com > > Compile-tested only (arm64 defconfig, W=1). > > drivers/irqchip/irq-gic-v3-its.c | 7 ++++--- > 1 file changed, 4 insertions(+), 3 deletions(-) > > diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c > index 282e4bafb084..7c5df91a317c 100644 > --- a/drivers/irqchip/irq-gic-v3-its.c > +++ b/drivers/irqchip/irq-gic-v3-its.c > @@ -5572,7 +5572,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; > > @@ -5582,7 +5581,8 @@ 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; nit: please don't split assignments. Long lines are perfectly fine. > np = of_find_matching_node(np, its_device_id)) { > if (!of_device_is_available(np) || > !of_property_read_bool(np, "msi-controller") || > @@ -5594,7 +5594,8 @@ 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; > With that addressed: Acked-by: Marc Zyngier M. -- Without deviation from the norm, progress is not possible.