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=1796383267; b=Gcjh9vg47zFDYtQSe3Xzs7vcLiVaijw2gVy2WG7Hxbdo2OrTCZryoOqeba7003Ds1Xgk 8TjzWWpP5Eb27MFfA2njHRRvsQFRTD/hW7+AoWA1a428d9pJbCf2K2k+6zudlmKpaZZSV uaMWd8VjJMKIAv4aSshkaFY584jSE49UEcqXsCjI98pttE1YuTr96MFxRZPfZ9DWxnvbC 7BUCotWIu3xFZl3d49/a74dew1xbWtYPQXH0qYxHYxKdV3eIUfuWeqckdFXU/rjWAD7B4 Maetavc6nki2fE8OoLcBm9/nq1Ndr9kRaLN2eWeuTZjlRiAAzIIs+sa3KZ0zhmoPjNQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796383267; 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=KJd4S+Ok0tpUu3wMXxnZPeQGH7I2ciD6geSF2cyt26M=; b=kzL5NRpdfKvHLs7pNnOZGQy4kMW71deq98WzqaW6hkLnEGEvLN1mAmwFro3Ls7kymFSQ o/h6eIr4rBP0XOGpaR074b+52BUB0bLsI4jHnhY7BS5wIsQAMqAwOuqBWFY6JIVTIyOqW Br3pZBBE1JOhbTwzZQP8f8rFa1zJQQvv2i6IJ6TpMCAFLpxmvL7E+Fr3FuTf2uY2zS4je re3k+QdjufQ+hYYyyGOcCqmM4Iw7WMFaLv9w7/xaFkJORJAe3MciF57FSO3VbcvJmRW4n TP7bApUMhIaWJcpbZ7WDdVgt/OVqzirQDieEn8qZamfIvNs5IAajrouHRseewQt2r+Q== 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="Pk6Yzr/j"; 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 B7535606A682; Fri, 4 Dec 2026 11:21:07 +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=Pk6Yzr/j Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2BA251F0092C; Fri, 4 Dec 2026 11:21:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796383267; bh=KJd4S+Ok0tpUu3wMXxnZPeQGH7I2ciD6geSF2cyt26M=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Pk6Yzr/jIIK4jGL52pyMZdndXC/63JEgWxBjwmq/dnkG5dYvgbM68tY5yaO5K3abL B/Hmw93F3P5ucrIqR5VA7F9B6luJMAn3E/SZD5E2DPabW8eY/BqXAlJjmTpyEGFuc8 sVGqEcOpVJJ62cIpHf3MJoV6DTEObhAIeeboyCxg= 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.12 154/555] irqchip/gic-v4: Unwind what its_alloc_vcpu_irqs() allocated on failure Date: Fri, 4 Dec 2026 19:03:17 +0900 Message-ID: <20261204100614.122237914@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100603.988357525@linuxfoundation.org> References: <20261204100603.988357525@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.12-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 91df31bed7105..1f6edd6e94e92 100644 --- a/drivers/irqchip/irq-gic-v4.c +++ b/drivers/irqchip/irq-gic-v4.c @@ -159,6 +159,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; @@ -189,11 +191,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); @@ -215,8 +220,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