From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 57BF312C462; Tue, 30 Apr 2024 11:04:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714475072; cv=none; b=Wf01eUpwFF5xlOgbnlrmQU+npdGLgRwA36g1YuNadab/zL+ZMnzo53yRdu6KnN6O9LGiO2tJlA8Gp+ZkcdozGLoQ7nzEE4VVJ4NDWfteCMECIX2Y6iQN5yAi2KF/AhhDR13JR9MvjqyDpHnMGAZYd9ZV+AhZ7neA+yTzG/qvF5U= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714475072; c=relaxed/simple; bh=UyjtlqQhd1djINb/td3UFda3xaPNluBPyWA6w1g8efs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=o0aMRccGnLPsJclktUd8dHdwR3BhN6aa939BNm6/AAeJsRpcx7cd7+BcVUniqMtwAM/FowX+wKyB26666bLf1WM7MjQxNYihuMyeEdSxt2HlqKPb2BIcDI5jPpeAr6PgmoVh6wzJlfSnzQMu//PWGn0R0TMtc3+t9V/oTPwLDPA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=0NDuARGF; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="0NDuARGF" Received: by smtp.kernel.org (Postfix) with ESMTPSA id CCB52C2BBFC; Tue, 30 Apr 2024 11:04:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1714475072; bh=UyjtlqQhd1djINb/td3UFda3xaPNluBPyWA6w1g8efs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0NDuARGFXGJbeawp0iybDtaEXrdqQY/G13IbVb4jrIpAIrBg4QjDT2y52BbQQa6lr qVS88GxblmsseP/EbRay3wiMEgjXWIQQh+sZhF7GYO0+/ubqHEOgLXvzqosG/7MAey acUuS8xf9Pc8HDKSTTGFBxXWtIv1NQ/Bu/7d7zps= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Guanrui Huang , Thomas Gleixner , Marc Zyngier , Zenghui Yu Subject: [PATCH 5.10 121/138] irqchip/gic-v3-its: Prevent double free on error Date: Tue, 30 Apr 2024 12:40:06 +0200 Message-ID: <20240430103052.967222301@linuxfoundation.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240430103049.422035273@linuxfoundation.org> References: <20240430103049.422035273@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.10-stable review patch. If anyone has any objections, please let me know. ------------------ From: Guanrui Huang commit c26591afd33adce296c022e3480dea4282b7ef91 upstream. 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 Signed-off-by: Greg Kroah-Hartman --- drivers/irqchip/irq-gic-v3-its.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) --- a/drivers/irqchip/irq-gic-v3-its.c +++ b/drivers/irqchip/irq-gic-v3-its.c @@ -4508,13 +4508,8 @@ static int its_vpe_irq_domain_alloc(stru set_bit(i, bitmap); } - 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; }