Received: by 2002:a89:48b:0:b0:1f5:f2ab:c469 with SMTP id a11csp1083114lqd; Thu, 25 Apr 2024 05:47:19 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVR4MpJeInsj3ZbukZHxzwoms4uIhLrMZBCRDxsuJCJVLRbsZ+XwqZZlOEyiL4DKwrdFdIy+bgVvo3gyjnqe5NlvHWMqjtYsCIvR1IgMg== X-Google-Smtp-Source: AGHT+IFLE5cDGz1vxylnYXUBjZF47/u5irD6tq0Ge23COgvmRQj5HUcYtfZbKNfOcOcc3h5OBDH1 X-Received: by 2002:a17:906:f9cd:b0:a58:c261:3e89 with SMTP id lj13-20020a170906f9cd00b00a58c2613e89mr111691ejb.31.1714049239070; Thu, 25 Apr 2024 05:47:19 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714049239; cv=pass; d=google.com; s=arc-20160816; b=cfgnvzLSC6ZRx0m/LfXn6zw5chNpO7GQzkWhm/lZD3NSHCCmk/J6PQ/aB8NQRMapR0 n/cUO8E68y6A6GQeOgfaMA9zLLxSYmcGwgcRqsvWafghEtj/Sp4t+KQKtHsGt+1wPHV1 8zb1YVW/6HBxicacq5wIRJEJUichO8WnKxseNqIm1uDbZcHvBfV29wH5suA2sRe0MV+u 1ciJjBCl84SQ9uz5+3XTvHXbL1TwhjcbdlDnbui/ppSx7x5WeUaPU9YN3izFtzPzUImu l6Cui7nKEB4V+IYAg1oVpm99h7HwSuwjQLjjyf/B5grj7bypYn6ppVbKFJsIkHt3a8U2 dOww== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:precedence:robot-unsubscribe:robot-id :message-id:mime-version:list-unsubscribe:list-subscribe:list-id :precedence:references:in-reply-to:cc:subject:to:reply-to:sender :from:dkim-signature:dkim-signature:date; bh=ga2NkwqsOM7kwwxlGdzjoHJHg6hep5Mj7xEr6EIAJqQ=; fh=KCNh4b41/3Kcq+D8quUbG9v3EJDYKWhPYapufChGmZE=; b=nWwermP6490C11YIJfiZ/PolmbOUyJQ9J5kc9QF0JGwNXHq4iMd9gNnBribsfXUlyg Nx1AcpIs9BLFMPuXCObVzGcT7VwKfbnlKFSoABCtWmubKcPyyCISnCP4NDFbkyqzy3RV yC31GU4e9TLKlFCbQLW6n+NnpAlrqscePozJ8jWZ2DwwRKAvlC2OjIxvdM0NQojxbZuk lvNOFYdbSU2344r508OG0AdqgG8OjEHKutw11i8s4Sig/eyWvnj+diImm8o6ROQsbQgG Zk8JHfUB/Svwbf3pfmKXJIYHu8/5SFGIN4mGgl3ohrVyXqfFvBcfJkgNc8coj/X2CW25 RBMw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=teygzRyc; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-158541-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-158541-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id nc12-20020a1709071c0c00b00a587300ebdasi4703886ejc.472.2024.04.25.05.47.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Apr 2024 05:47:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-158541-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=teygzRyc; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; arc=pass (i=1 spf=pass spfdomain=linutronix.de dkim=pass dkdomain=linutronix.de dmarc=pass fromdomain=linutronix.de); spf=pass (google.com: domain of linux-kernel+bounces-158541-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-158541-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 6CC081F2402A for ; Thu, 25 Apr 2024 12:47:04 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4D0E91494D4; Thu, 25 Apr 2024 12:46:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="teygzRyc"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="zEe+3NXf" Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 1C5A71494BC; Thu, 25 Apr 2024 12:46:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714049212; cv=none; b=MI3QcGp8etPHj/Ot+SzrE+HtF3ufoExrXH2tCHmPCuB3lC9yUQrvfC0Rkz1n5KIpkygg69g9A9gxKiP2sJEdSlLeDtxPfbANJ70O3aWzB1o/WqaUFHGOPjnYJCeqVM+OrzwxzPKtC4/o2iu8s5d6Ns/4F9a+cCF5/CFR7bN1d/o= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714049212; c=relaxed/simple; bh=J/Z3SHdqPZtbUOyL9ZHiIg5YILYMIAg4ajSMNaH57E0=; h=Date:From:To:Subject:Cc:In-Reply-To:References:MIME-Version: Message-ID:Content-Type; b=V5Vjp85AtEL0chTFFJg4E6gscyTGFY76fZRhIkVs5Nw0wwYGj9uFAWo5qKVdxnZOPHd2iYWdTN2bRxzjMqgNrYr6Y+rh/qBnS1QVHv5AYBrLlBJxFh756JpgDwYiZMY7CDNitx183xYxUcQn8pBr3dkovBC5fb5mUHIOsWClw6c= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=teygzRyc; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=zEe+3NXf; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Date: Thu, 25 Apr 2024 12:46:49 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1714049209; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ga2NkwqsOM7kwwxlGdzjoHJHg6hep5Mj7xEr6EIAJqQ=; b=teygzRycPyoAAZu0zK09LCzrnd6AC0Kc1QhN2PLZVhcH2po/I/Vj0wvbGal9YOAys5yc68 vGDRa2yPVvbJ826oIjV5HxUrTT6zJuWtf8lUPPEGPKyiP5+Hkvghqbac2pxHYj1HJWO5un H0l9TLXkc4sEFgmAZCHUIXwLe3thIY56gGbspHPWydLc0IzO3FNfyhEGYLCZv0O+OnnsWa +aEyxEtbKj9wGliZhAS6cDLnbUlYYgLUINE5WPX4EwMR7eYSD+tzZXmmI+B8xKfSwNgXRu 3U7pgcRcPw70CEplQ9RGYKH/Eh29VP9FE4GTMveLOYLdROfyaB3jL2LR0EObaQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1714049209; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ga2NkwqsOM7kwwxlGdzjoHJHg6hep5Mj7xEr6EIAJqQ=; b=zEe+3NXfAdqmfQd6tEEe2lvP1PYkXu9yMntk0wPCgOvmrmfQVqUbg7SMRuh4+dS51X3KGV xdWWibmoI3QnTpBw== From: "tip-bot2 for Guanrui Huang" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: irq/urgent] irqchip/gic-v3-its: Prevent double free on error Cc: Guanrui Huang , Thomas Gleixner , Marc Zyngier , Zenghui Yu , stable@vger.kernel.org, x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20240418061053.96803-2-guanrui.huang@linux.alibaba.com> References: <20240418061053.96803-2-guanrui.huang@linux.alibaba.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <171404920906.10875.16509237626955836035.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Precedence: bulk Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit The following commit has been merged into the irq/urgent branch of tip: Commit-ID: c26591afd33adce296c022e3480dea4282b7ef91 Gitweb: https://git.kernel.org/tip/c26591afd33adce296c022e3480dea4282b7ef91 Author: Guanrui Huang AuthorDate: Thu, 18 Apr 2024 14:10:52 +08:00 Committer: Thomas Gleixner CommitterDate: Thu, 25 Apr 2024 14:30:46 +02:00 irqchip/gic-v3-its: Prevent double free on error The error handling path in its_vpe_irq_domain_alloc() causes a double free when its_vpe_init() fails after successfully allocating at least one interrupt. This happens because its_vpe_irq_domain_free() frees the interrupts along with the area bitmap and the vprop_page and its_vpe_irq_domain_alloc() subsequently frees the area bitmap and the vprop_page again. Fix this by unconditionally invoking its_vpe_irq_domain_free() which handles all cases correctly and by removing the bitmap/vprop_page freeing from its_vpe_irq_domain_alloc(). [ tglx: Massaged change log ] Fixes: 7d75bbb4bc1a ("irqchip/gic-v3-its: Add VPE irq domain allocation/teardown") Signed-off-by: Guanrui Huang Signed-off-by: Thomas Gleixner Reviewed-by: Marc Zyngier Reviewed-by: Zenghui Yu Cc: stable@vger.kernel.org Link: https://lore.kernel.org/r/20240418061053.96803-2-guanrui.huang@linux.alibaba.com --- drivers/irqchip/irq-gic-v3-its.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c index 2a537cb..5f7d3db 100644 --- a/drivers/irqchip/irq-gic-v3-its.c +++ b/drivers/irqchip/irq-gic-v3-its.c @@ -4567,13 +4567,8 @@ static int its_vpe_irq_domain_alloc(struct irq_domain *domain, unsigned int virq irqd_set_resend_when_in_progress(irq_get_irq_data(virq + i)); } - if (err) { - if (i > 0) - its_vpe_irq_domain_free(domain, virq, i); - - its_lpi_free(bitmap, base, nr_ids); - its_free_prop_table(vprop_page); - } + if (err) + its_vpe_irq_domain_free(domain, virq, i); return err; }