From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1794388589; b=Wd0vXcStiLjSHUWTwc89lPfTL/WcGrvFYxLI+/t5zEXIT1rtf8xLP0kdVl03oEhRB2dT 6QzEN7QwfSTu8WafIC/SieVFIoaicM6Kfs0ihJZq+oxPXtFsJ7ad6LjS3dVLrCD8HHhbg TMrwNoUxrRG3y4EIdg23eHUahRVbN9muS6wOhk/hoRQt2N9fC9CRsiswDa+rWb2wSZb5q j/oia4/366LVEUC0rBYvJCx2d/UUXZEGGwvMZUWKuj8wTdXb5+O02L53of1UeNr81d0MX G7Uh794A8tt6Vq5/iEQLUBMdSogVRO+V8oJkwQR9prEV0/+OqRsrWM+P2IUV4kA79kA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794388589; h=Received:DKIM-Signature:Received:Date:Message-ID:From:To:Cc:Subject: In-Reply-To:References:User-Agent:MIME-Version:Content-Type: X-SA-Exim-Connect-IP:X-SA-Exim-Rcpt-To:X-SA-Exim-Mail-From: X-SA-Exim-Scanned; bh=/kxyqAjTx8NKkvcCIqcp+hxivFQPr/EPfwfGlYdXLBo=; b=dJOaVdt8z/Ojma9U5YR8RGOCDcheQpqdOWAmiQmDRVEac1BbypxJ7z4oiLxP+1T8iF5m H0za7FnEzDFMc4j1GkLY4gWbMe+kPhV7ItMgCHTK+tKrH8bHUvbZRi/steiScdNErf5jh OaKrz/V5HLDrrYzN4L2kiMK/dAyk7DZhLnuXoVoXz2lSM/yyMkJwlzaUr58bwMgkzazXq Qk3KH/uD6ZxjZEWNQwbiWTaVMV3J3dIhsMngVRrmz9S2l4LtOHfwLirT6g+uSY4ECqhqW nyYuPHp/s9cCsCErgbnbBXDSvRdLIN1gc3xQYfJ19LWTZI0kNprPtJ/7k8765vwV46w== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=P7A1TJfi; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0E74E606A324 for ; Wed, 11 Nov 2026 09:16:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=P7A1TJfi 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-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list 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 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.