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 113DEC5320E for ; Mon, 19 Aug 2024 09:47:27 +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=ocv0xlwVU6zj7eiO+RmH1C913+NA3MCCZ03oK0mEn5A=; b=YI8++FNIfi5dvp/i4XhEXoqmJ3 jEkWnophq16KBWD9LuAzCys1dUvzYS0jUfaShcxtV8M3Hqq82LYb++w9V6h/U27ifmj5FsndOtiyl TwneGa52Wjo+Cu8ezNQ4V6PH97OblwStNdA0pyyYufwd7FB5AgjYPJtAiLeaHE2m+aLrTFdZSTm/p 9xA7lKEuJ4locYC+lHgGZGHcQUzealHLGvtNw1gUdnOIXbFOUbcUTKLnUm89A0HRBGsNhpijFiNzd TP17cNuMfdK3+ZgcYqFw8BCukMhF1Fj9Qn3yo4XebbXVMetZoKJEEVUHXiGekMCuWuF+VN+bZ/LE6 0AiShhsA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sfyyp-0000000113p-0MsD; Mon, 19 Aug 2024 09:47:15 +0000 Received: from sin.source.kernel.org ([145.40.73.55]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sfyxL-000000010jT-32JO for linux-arm-kernel@lists.infradead.org; Mon, 19 Aug 2024 09:45:45 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 11575CE09B9; Mon, 19 Aug 2024 09:45:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 445D0C32782; Mon, 19 Aug 2024 09:45:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1724060741; bh=YS/8TiJFBdjMRL1xjOBFUMV2FIcDFujd6QrtyTla/zQ=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=s5x+a2zC5SDQWxuHaXQyn3FmtHEXKyHUYwPe3V4QjSWF8l+tCL4hbewNwaxazMKEJ ZtZBxQYM9FlP6Ln+WDnauOfQtCxko4aq5JxuszY67j7Dd24pMGv7vr9PSfIbCYea9N 7qFO/mAmMkSZ8WMl3xG3HCUDQ9OY+MxAdNYsyhxWkpGVe+YNdJidIp+YGFs7SensMl XokHXzvBjtuWtjLS8tiheK8nUePhzKMnaRgaELN7iq/+eecKSPULIh0c9K7UzgPLY+ byeGC5TxAGUGjxwJcLCK5GzGsnPfvatepq2I0mK2mFORqivYgWXPUbrautnz6+z6ws G6L3wE/ACvszA== 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.95) (envelope-from ) id 1sfyxG-004rgz-R8; Mon, 19 Aug 2024 10:45:39 +0100 Date: Mon, 19 Aug 2024 10:45:38 +0100 Message-ID: <864j7gzvzx.wl-maz@kernel.org> From: Marc Zyngier To: Ma Ke Cc: tglx@linutronix.de, Suravee.Suthikulpanit@amd.com, akpm@linux-foundation.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: Re: [PATCH] irqchip/gic-v2m: Fix refcount leak in gicv2m_of_init In-Reply-To: <20240819091011.1015745-1-make24@iscas.ac.cn> References: <20240819091011.1015745-1-make24@iscas.ac.cn> 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/29.4 (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: make24@iscas.ac.cn, tglx@linutronix.de, Suravee.Suthikulpanit@amd.com, akpm@linux-foundation.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, stable@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-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240819_024543_957995_B39204C7 X-CRM114-Status: GOOD ( 21.12 ) 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 Mon, 19 Aug 2024 10:10:11 +0100, Ma Ke wrote: > > Add the missing of_node_put() to release the refcount incremented > by of_find_matching_node(). > > Cc: stable@vger.kernel.org > Fixes: 4266ab1a8ff5 ("irqchip/gic-v2m: Refactor to prepare for ACPI support") > Signed-off-by: Ma Ke > --- > drivers/irqchip/irq-gic-v2m.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/drivers/irqchip/irq-gic-v2m.c b/drivers/irqchip/irq-gic-v2m.c > index 51af63c046ed..65a55ee7bb30 100644 > --- a/drivers/irqchip/irq-gic-v2m.c > +++ b/drivers/irqchip/irq-gic-v2m.c > @@ -396,6 +396,7 @@ static int __init gicv2m_of_init(struct fwnode_handle *parent_handle, > ret = of_address_to_resource(child, 0, &res); > if (ret) { > pr_err("Failed to allocate v2m resource.\n"); > + of_node_put(child); > break; > } > Although this indeed fixes a minor issue, it is probably better to unify all the failure conditions. Something like this (untested): diff --git a/drivers/irqchip/irq-gic-v2m.c b/drivers/irqchip/irq-gic-v2m.c index 51af63c046ed..d5988012eb40 100644 --- a/drivers/irqchip/irq-gic-v2m.c +++ b/drivers/irqchip/irq-gic-v2m.c @@ -407,12 +407,12 @@ static int __init gicv2m_of_init(struct fwnode_handle *parent_handle, ret = gicv2m_init_one(&child->fwnode, spi_start, nr_spis, &res, 0); - if (ret) { - of_node_put(child); + if (ret) break; - } } + if (ret && child) + of_put_node(child); if (!ret) ret = gicv2m_allocate_domains(parent); if (ret) Thanks, M. -- Without deviation from the norm, progress is not possible.