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 5C548C4451B for ; Mon, 20 Jul 2026 09:11:58 +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=dQb+2X9nWD1OWaKa2Fs9dIHuK0dsQwtZUMEcjYtHnmE=; b=FPFKR9ef+MRQx7LQvvf75jiDi3 VdngxWdWs4jE26z3cPN+fd34I4BbBT5gbNZAkIRwJzSimw5ZEK8YJRJsQI/gh3We5ZtsJhLgmYCUu AL4xE+lxDG4INdkqnRTWeTcpFPQ5ITXKMmzML8Xo5rt+ZcRWEVoWRhSsP4q+4maPm2qaNNlq/VLGP 1KmQoANYpEGADItheStFpEMoI6kKGt/vCEj2H8Gb5idvaN5cJWc78cc2HDqsz+Ee2umkLJ8TyPgp1 S/CTXqjU1GUBUocTQ4KzYQKHsnsfDcMXRCR5kmccD/13EQRTQ8oF+o7Yz5qAKx5UY4TBF1VfBUv/J BDHQ23Ig==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.99.1 #2 (Red Hat Linux)) id 1wljhZ-00000006Edi-2W5z; Mon, 20 Jul 2026 08:50:17 +0000 Received: from sea.source.kernel.org ([2600:3c0a:e001:78e:0:1991:8:25]) by bombadil.infradead.org with esmtps (Exim 4.99.1 #2 (Red Hat Linux)) id 1wljhY-00000006Eda-2PaT for linux-arm-kernel@lists.infradead.org; Mon, 20 Jul 2026 08:50:16 +0000 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by sea.source.kernel.org (Postfix) with ESMTP id 1B1CE40B43; Mon, 20 Jul 2026 08:50:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id F10581F00A3A; Mon, 20 Jul 2026 08:50:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1784537414; bh=dQb+2X9nWD1OWaKa2Fs9dIHuK0dsQwtZUMEcjYtHnmE=; h=Date:From:To:Cc:Subject:In-Reply-To:References; b=W6+7GQnTvp/U1tBNUQLniJ8G1ZlpIRwtoo8U0EHTZXI2umyhL9DeCua9HLScuT66u pfzjTnynk8iVURi/ZXFnF+k0fiFS4MeSobSeLVXmC6ZI+Mtm+Xaqvz8fhPDay8OfBv +mGONREH7LHi6RH3ZDqnpEFFYGiSTN5usVx2LqP6woyo5aaWw4wu8P47Kqw85mhXiS Dw+IluOBtOwHi/j85QNRuHDDbF7FzgM2ZbreRIVO+jW5zQ9W50bw5GIOYeaVUusaJl 6yxD5LKZ3xiHvkOi5LtVTHLJXIJ0kKJnvpaQPSUUMqAY8Q3IanXaoSPLWCaZYBSKLX Pk2HKjjBy4Duw== 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 1wljhT-00000006hya-30L6; Mon, 20 Jul 2026 08:50:11 +0000 Date: Mon, 20 Jul 2026 09:50:00 +0100 Message-ID: <86a4rmf3k7.wl-maz@kernel.org> From: Marc Zyngier To: Kemeng Shi Cc: tglx@kernel.org, jason@lakedaemon.net, lpieralisi@kernel.org, radu@rendec.net, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v5 3/4] irqchip/gic-v3-its: Fix leak in its_vpe_irq_domain_alloc() In-Reply-To: <20260720071215.50705-4-shikemeng@huaweicloud.com> References: <20260720071215.50705-1-shikemeng@huaweicloud.com> <20260720071215.50705-4-shikemeng@huaweicloud.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) 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: shikemeng@huaweicloud.com, tglx@kernel.org, jason@lakedaemon.net, 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-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, 20 Jul 2026 08:12:14 +0100, Kemeng Shi wrote: > > When its_irq_gic_domain_alloc() fails, the following > its_vpe_irq_domain_free() skips calling its_vep_teardown() for the > corresponding irq. Try its_vpe_teardown() in error handling to avoid > the leak issue. > > Fixes: 7d75bbb4bc1ad ("irqchip/gic-v3-its: Add VPE irq domain allocation/teardown") > Signed-off-by: Kemeng Shi > --- > drivers/irqchip/irq-gic-v3-its.c | 12 ++++++++---- > 1 file changed, 8 insertions(+), 4 deletions(-) > > diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c > index 3e4edcb64065..5dc91862fc15 100644 > --- a/drivers/irqchip/irq-gic-v3-its.c > +++ b/drivers/irqchip/irq-gic-v3-its.c > @@ -4594,9 +4594,11 @@ static int its_vpe_init(struct its_vpe *vpe) > > static void its_vpe_teardown(struct its_vpe *vpe) > { > - its_vpe_db_proxy_unmap(vpe); > - its_vpe_id_free(vpe->vpe_id); > - its_free_pending_table(vpe->vpt_page); > + if (vpe->vpt_page != NULL) { > + its_vpe_db_proxy_unmap(vpe); > + its_vpe_id_free(vpe->vpe_id); > + its_free_pending_table(vpe->vpt_page); > + } Please keep the diff minimal by doing an early return. This also deserves a comment, because this is not completely obvious: diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c index 6f5811aae59c1..38032067135b6 100644 --- a/drivers/irqchip/irq-gic-v3-its.c +++ b/drivers/irqchip/irq-gic-v3-its.c @@ -4592,6 +4592,13 @@ static int its_vpe_init(struct its_vpe *vpe) static void its_vpe_teardown(struct its_vpe *vpe) { + /* + * If vpt_page is NULL, then its_vpe_init() has failed, and + * there is nothing to do as no resource has been allocated. + */ + if (!vpe->vpt_page) + return; + its_vpe_db_proxy_unmap(vpe); its_vpe_id_free(vpe->vpe_id); its_free_pending_table(vpe->vpt_page); M. -- Without deviation from the norm, progress is not possible.