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 5298E3F86F8 for ; Mon, 6 Jul 2026 08:36:57 +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=1783327023; cv=none; b=KHsrWR4T4YaKUjLZg91VDSrbozxae8p8W9r2beVNOkN2lrL7ByhiE4hwzXU26lf4AFjeuCjheufuypusiIgtwD4xSrTRBWuUvgeq739aEVLoVz/8+wKp1YOZIVTCzRu9IeH1jedrovWBzJ7Nts+EiERlQupZsOY+U3KDAZFt7Jw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783327023; c=relaxed/simple; bh=iFVV4oVY3IEbKa4NV5W/1aKBbUBofdQ13CFKhp62QmA=; h=Date:Message-ID:From:To:Cc:Subject:In-Reply-To:References: MIME-Version:Content-Type; b=D4FoEY5qxrx01jtPzUSl64Umiwj88P6pINflKFWRWW66GBd7fPrZu6OlAA+rkt6cosOrgE+bbUQ0NYN1PmVBhqRrCjZ+CbYXa+qLq5RDxa02AgF/ful+F5ea1jBvB7rOaEFF3yFJ9RFMVjaK3s6rlyrDYLHn4swe1OVJBcMRkFc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=PcYxcTJq; 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="PcYxcTJq" 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) 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=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 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.