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 A7BC7C43458 for ; Mon, 6 Jul 2026 08:37:03 +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-Transfer-Encoding: Content-Type:MIME-Version:References:In-Reply-To:Subject:Cc:To:From: Message-ID:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=XaBATfLb4OZrYx23dgdvewHU5sXZqmVbCgA0UDYpqHI=; b=DXwdSZXyW/+FV/UhpRYr2wNKBz DZ4NsY1dJY+8fnLfGbeG0VkbpuGk/BRLeySD+BZOmPZ2t5v5uT7v+NUCyG7M5xW1FTnJqesf6W+sP /C/DmLri5VkiDGkbgT88u5Bn+2HKB3VXFi5L9YKn+Zr5Pu63en0qul7JTa1L2Np69x5wVqwgB1kYN 8zpKt7QZIMONGCi6k47J9rPWUhG6pLpF69FnKd+VnhvClLIaAmeAtbaf3yB7uW34V+9nHfISqtezu ucw0NlkEtcxvKKugfigheY+GwzpOxh6S+2zrSDUKL1JhQrFg22iIf0g6Ya6FnuJA2Pf6uSTNZ4Iwt bMVLeSGw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.99.1 #2 (Red Hat Linux)) id 1wgeoy-0000000Bqbl-3P4T; Mon, 06 Jul 2026 08:36:56 +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 1wgeox-0000000BqbY-1YmH for linux-arm-kernel@lists.infradead.org; Mon, 06 Jul 2026 08:36:55 +0000 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by sea.source.kernel.org (Postfix) with ESMTP id B261F40BDA; Mon, 6 Jul 2026 08:36:54 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 942BD1F00A3A; Mon, 6 Jul 2026 08:36:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1783327014; bh=XaBATfLb4OZrYx23dgdvewHU5sXZqmVbCgA0UDYpqHI=; h=Date:From:To:Cc:Subject:In-Reply-To:References; b=PcYxcTJq/+qEahkF3CFjNq+QGWvOhZqzsr7M6UL7wXIXG08AzfvQb3oNje9/CBFNK pzRW/lZTw9JJ8SG1lHgZjuykmHPim8Rv5TtsooAPGunVx7FEJWX6U5oLBAJ1wulfQI x3lXHhvVDK0rsrDwHvP9ZV9TF5V5A5z6sdNuwkuvs1qqamZlSm9JbyH6nQXfO/NnuB m9Vzjfgfxf4AJcdSb1R6JJ1dl+80i3749YDm2us6HDCSHXikx7oBMH7GRAyPRPNPSc n22DeDrFcduw9IJN8D7F0mT5wIil/PHLCekLwr4Y5e8qd0x01y62bmn6APQ5FzO0P2 dwhwLhC9pFGKA== 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 1wgeou-00000001oqq-1tGL; Mon, 06 Jul 2026 08:36:52 +0000 Date: Mon, 06 Jul 2026 09:36:52 +0100 Message-ID: <86ldbopl97.wl-maz@kernel.org> From: Marc Zyngier To: Kemeng Shi Cc: tglx@kernel.org, jason@lakedaemon.net, lpieralisi@kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v4 3/6] irqchip/gic-v3-its: Fix leak in its_vpe_irq_domain_alloc() In-Reply-To: References: <20260702033050.1583-1-shikemeng@huaweicloud.com> <20260702033050.1583-4-shikemeng@huaweicloud.com> <87fr216nx2.wl-maz@kernel.org> 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=UTF-8 Content-Transfer-Encoding: quoted-printable 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, 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 Fri, 03 Jul 2026 02:44:53 +0100, Kemeng Shi wrote: >=20 > =E5=9C=A8 2026/7/3 6:12:57, Marc Zyngier =E5=86=99=E9=81=93: > >> When its_irq_gic_domain_alloc() fails, the following > >> its_vpe_irq_domain_free() skips calling its_vep_teardown() for the > >> corresponding irq. Call its_vpe_teardown() when its_irq_gic_domain_all= oc() > >> is failedto avoid the leak issue. > >> > >> Fixes: 7d75bbb4bc1ad ("irqchip/gic-v3-its: Add VPE irq domain allocati= on/teardown") > >> Signed-off-by: Kemeng Shi > >> --- > >> drivers/irqchip/irq-gic-v3-its.c | 4 +++- > >> 1 file changed, 3 insertions(+), 1 deletion(-) > >> > >> diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gi= c-v3-its.c > >> index 3e4edcb64065..8968bedefdba 100644 > >> --- a/drivers/irqchip/irq-gic-v3-its.c > >> +++ b/drivers/irqchip/irq-gic-v3-its.c > >> @@ -4666,8 +4666,10 @@ static int its_vpe_irq_domain_alloc(struct irq_= domain *domain, unsigned int virq > >> break; > >> err =3D its_irq_gic_domain_alloc(domain, virq + i, > >> vm->vpes[i]->vpe_db_lpi); > >> - if (err) > >> + if (err) { > >> + its_vpe_teardown(vm->vpes[i]); > >> break; > >> + } > > There is already a spot for error handling in this function, we don't > > need a second one. > When its_irq_gic_domain_alloc() fails at index i, its_vpe_init(vpes[i]) > has already succeeded but the exisiting its_vpe_irq_domain_free(domain, v= irq, i) > only tears down VPEs with index [0, i - 1], so its_vpe_teardown(vpes[i]) = is still > needed. > So I guess you mean we can increase index when its_irq_gic_domain_alloc()= fails to > free the resource with existing error handling? > Please correct me if I'm miss anything. What I mean is this. M. =09 diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-= its.c index b57d81ad33a0a..4b1a3b497d7c4 100644 --- a/drivers/irqchip/irq-gic-v3-its.c +++ b/drivers/irqchip/irq-gic-v3-its.c @@ -4674,8 +4674,10 @@ static int its_vpe_irq_domain_alloc(struct irq_domai= n *domain, unsigned int virq irqd_set_resend_when_in_progress(irq_get_irq_data(virq + i)); } =20 - if (err) + if (err) { + its_vpe_teardown(vm->vpes[i]); its_vpe_irq_domain_free(domain, virq, i); + } =20 return err; } --=20 Without deviation from the norm, progress is not possible.