From nobody Mon Sep 15 00:04:19 2025 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 A5F6DC63797 for ; Tue, 17 Jan 2023 14:47:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230354AbjAQOri (ORCPT ); Tue, 17 Jan 2023 09:47:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34314 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231955AbjAQOrb (ORCPT ); Tue, 17 Jan 2023 09:47:31 -0500 Received: from relay10.mail.gandi.net (relay10.mail.gandi.net [217.70.178.230]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9A6B534C1B; Tue, 17 Jan 2023 06:47:29 -0800 (PST) Received: (Authenticated sender: clement.leger@bootlin.com) by mail.gandi.net (Postfix) with ESMTPSA id B1FCF240013; Tue, 17 Jan 2023 14:47:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1673966848; h=from:from: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; bh=/cUfcf/QAMo2QYFX45p/y6/QB8475Ld6Zy/Yz1xqXFw=; b=Mq+6FxmjcHlOqY5XywZGT2jCVdK0oUcGNv5QalgRxYRvmbE6w2Kc+pKimT7Uv5+BHEyWXG LwwpgTBRPexNHsKUcdYcw4BVQwT9YROK2IiYG2ji6L93rm52wPxNBUfBl5sk8+GcyRPzez LzIXBHOji8Uo9UgFR32ZRo2OxVHwFFeUF4ShSDr362vkHN+IqgS7XT+F+9U/0oVjJCorTh R/clqcpuUDTjwH9evgegoBIpkdElW2ORr3KgRhC61Jg0eJo57rsDgB38QGavBd+HVTFEYO mXdMe2NS2oewxs8zVUWpOSy9HynfxycbKJSqcvys5fIccy7Hnh8zcMg2x53fCA== From: =?UTF-8?q?Cl=C3=A9ment=20L=C3=A9ger?= To: Rob Herring , Frank Rowand Cc: =?UTF-8?q?Cl=C3=A9ment=20L=C3=A9ger?= , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] of/irq: add missing of_node_put() for interrupt parent node Date: Tue, 17 Jan 2023 15:49:29 +0100 Message-Id: <20230117144929.423089-1-clement.leger@bootlin.com> X-Mailer: git-send-email 2.39.0 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org After calling of_irq_parse_one(), the node provided in the of_phandle_args has a refcount increment by one. Add missing of_node_put in of_irq_get() to decrement the refcount once used. Signed-off-by: Cl=C3=A9ment L=C3=A9ger --- While debugging a refcount problem with OF_DYNAMIC enabled (which is actually the only case were node refcount are really used), I noticed that platform_get_irq() was actually incrementing the refcount of an interrupt controller node. Digging into that function shows that it calls of_irq_get() which calls of_irq_parse_one() and finally of_irq_parse_raw(). Since it seems sane that the node returned in the of_phandle_args has a refcount incremented, I thought it is better to put the of_node_put() in the user even though it was hard to find any user doing so. drivers/of/irq.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/of/irq.c b/drivers/of/irq.c index e9bf5236ed89..174900072c18 100644 --- a/drivers/of/irq.c +++ b/drivers/of/irq.c @@ -438,10 +438,16 @@ int of_irq_get(struct device_node *dev, int index) return rc; =20 domain =3D irq_find_host(oirq.np); - if (!domain) - return -EPROBE_DEFER; + if (!domain) { + rc =3D -EPROBE_DEFER; + goto out; + } =20 - return irq_create_of_mapping(&oirq); + rc =3D irq_create_of_mapping(&oirq); +out: + of_node_put(oirq.np); + + return rc; } EXPORT_SYMBOL_GPL(of_irq_get); =20 --=20 2.39.0