From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F422B4AA01A for ; Thu, 24 Sep 2026 20:12:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790280767; cv=none; b=l0nUlfDELJz9aTQ/F3n+Fdpys2hr8wDbOdxVW7z8iowWAnbtmXqvSx6+TSXCnozVDfRU1u3bo5QazvwugpfIciw2jVsrVXOsbF/xm8+nLDtFe0GIskF/QL6jxOKZi2R0gIK4hryz0NC5iyOLAAlGdySWFBH1jOBEVq37D9dgQc0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790280767; c=relaxed/simple; bh=ZBDkKPIIYOofedavAgyTBQfxZIRZXkLBBBL2Ypspx+s=; h=Date:Message-ID:From:To:Cc:Subject:In-Reply-To:References: MIME-Version:Content-Type; b=jw03ojwisySHgb2PzdEMsXjq4Abi1uXQdZlu81aw+r+ePHXU5qzjCvIjvyn09K1CCKpfw4dinw8AqgYiTSP+Z9hqYbifC0l1ioW7dUo5jrCLS+qkseDrcS6qrYRAQP7XKaQP5Q/dsqT9lfNvdtZoXG1WCD3w1hzTZeAIxrnRtLc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=dfGGI8k/; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="dfGGI8k/" 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) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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 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.