From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796386202; b=wbi94IBW4mAreIhNY258+ZtkfdSNThEmqe5ZMJc3O2TAqQCUVM09VMCyuSnkCfabuF4P OU8+8ijmsetwCSI61QfXEpkPDAJuJYuWxKuUh5hkFYLfvMhyayhnUhstw0C23Sjfd+/cv emA99qtiIeDpCsPJAce5v0RqGCieFynltyq9Q9ZRz6AFO/xuGf1pE4/eOLkPqqBbhnnkV 79Y+hjhYOmL/5XhMyxyM2cv57Hp7pTUIGI3oHPkyFEl8Cjn/1Yfzxgr3S9nI08Ufr5tDh EsvDHpSqLYp8hIeZluj5XgJYhpQWmpdE3KYoxTj+rMBzCe+Ion8P0lH+rm4Xh1H5mFQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796386202; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=qDMu0oHZo5ni+AfP2g6+U69WLwiJJfTrdnINOtWXd0Y=; b=NgU7weoyN8Z7YH0CkRESGU/6aFaN9z9+zOtadY+R4hBOokRz8c/nyPsP1cx3Qv4VRlp3 dwKLjw58NHIWHnTu8IABx7jBcpy9beR7H5Oe2YfbBJvgBb2ssbyBkyLtdVcXumSNuLKca znZIEccGONrQVzaHcvriG/fplWodKMWv6DwYdaayUJobNiZj8NzOUplJVZFjR9BDgxPTw pPGkRBP0ctY5Lb8zZPr/Bs3WlLrSfv54gsOsToPhdnZ8IuZ8HRhIDuFgpIaX/BUX0mAkC T4UU2cS3+R1msW6m/NPlA61g5uIFnFlm7ZPEQmpWJn5lIdgWdPzL2B2HIsNZ4VZXNcg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=BfZuaLbj; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E83A5606A322; Fri, 4 Dec 2026 12:10:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=BfZuaLbj Received: by smtp.kernel.org (Postfix) with ESMTPSA id 604B01F000C2; Fri, 4 Dec 2026 12:10:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796386201; bh=qDMu0oHZo5ni+AfP2g6+U69WLwiJJfTrdnINOtWXd0Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=BfZuaLbjtEpUMDNkXXnrpCjS3FPJ1Sw2JGLfp5/aw7JwJ6vgbYNwu69QjsO9pTsla P7/rm/lqK9h5DzuSsMlLpsiljV2waGNcqsf+s89TKfqSeUrokNO5jBC2bHfWCYSeV8 eZlC0Ajf2Rsfgg5ldXiB2RI8jS5F+gCAvpjeKEV0= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Yuan Yao , Fuad Tabba , Marc Zyngier , Sasha Levin Subject: [PATCH 6.6 0851/1167] irqchip/gic-v4: Unwind what its_alloc_vcpu_irqs() allocated on failure Date: Fri, 4 Dec 2026 19:04:38 +0900 Message-ID: <20261204100724.288100380@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100702.047403948@linuxfoundation.org> References: <20261204100702.047403948@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Fuad Tabba [ Upstream commit fd86d69c951765e24e89a162c53dfe33a8aba976 ] A failure in the its_alloc_vcpu_sgis() loop leaves behind both the SGI domains created for the vPEs below the failing index and the vPE irqs allocated before the loop, since irq_domain_remove() frees neither. Each leaked vPE takes its ITS state with it, a vpe_id and an LPI pending table. Free both from a second label before the existing unwind. With the freed pointers now cleared, its_free_sgi_irqs() can skip a vPE with no SGI domain and be reused there. The check has to precede the lookup: irq_find_mapping(NULL, 0) falls back to irq_default_domain, and the live irq it returns would then be freed. Fixes: 6d31b6ff985d ("irqchip/gic-v4.1: Add VSGI allocation/teardown") Reviewed-by: Yuan Yao Signed-off-by: Fuad Tabba Link: https://patch.msgid.link/20260921072958.2918477-3-fuad.tabba@linux.dev Signed-off-by: Marc Zyngier Signed-off-by: Sasha Levin --- drivers/irqchip/irq-gic-v4.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/drivers/irqchip/irq-gic-v4.c b/drivers/irqchip/irq-gic-v4.c index 2597f1404d0cb..b6821e734579f 100644 --- a/drivers/irqchip/irq-gic-v4.c +++ b/drivers/irqchip/irq-gic-v4.c @@ -158,6 +158,8 @@ static int its_alloc_vcpu_sgis(struct its_vpe *vpe, int idx) return -ENOMEM; } +static void its_free_sgi_irqs(struct its_vm *vm); + int its_alloc_vcpu_irqs(struct its_vm *vm) { int vpe_base_irq, i; @@ -188,11 +190,14 @@ int its_alloc_vcpu_irqs(struct its_vm *vm) vm->vpes[i]->irq = vpe_base_irq + i; ret = its_alloc_vcpu_sgis(vm->vpes[i], i); if (ret) - goto err; + goto err_free_irqs; } return 0; +err_free_irqs: + its_free_sgi_irqs(vm); + irq_domain_free_irqs(vpe_base_irq, vm->nr_vpes); err: if (vm->domain) { irq_domain_remove(vm->domain); @@ -214,8 +219,13 @@ static void its_free_sgi_irqs(struct its_vm *vm) return; for (i = 0; i < vm->nr_vpes; i++) { - unsigned int irq = irq_find_mapping(vm->vpes[i]->sgi_domain, 0); + unsigned int irq; + + /* irq_find_mapping() falls back to the default domain on NULL. */ + if (!vm->vpes[i]->sgi_domain) + continue; + irq = irq_find_mapping(vm->vpes[i]->sgi_domain, 0); if (WARN_ON(!irq)) continue; -- 2.53.0