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 9E4BC12BF32; Tue, 30 Apr 2024 11:29:56 +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=1714476596; cv=none; b=Inp2Nl+qYpuaOnoW4m59Qhb9E4/c3xtFELig9w/g8n8v+C2TndsGkKbjAN9QiVOrouFXIjENyhgeUCon7fN5w95f5kH3sqA1Ylz1tJ+6ZHvG0wzgUJUhHswhAbujI9r/8Yl5lH1JehObOhnkLiENi8lamhxK2utYePCZdCs1CzA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714476596; c=relaxed/simple; bh=UWkDCFnZ61yO6SAwL6rskwlSmq/KozOJXKlqVHpd6JM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=TH+hZAO9RzUJY1diqH26D1WZQL1cLHdpvjIWV7WJbyAGaoE3jJxXrtqosqdLOqJkTIXmYYZnJYizjpZEp4kApBzWn1pCz+TwNMUww27ejmFUUjxCwI3RfuQCJpLgq2XrfG44qTVaniIwid9KZdshu/0a97Ri1zn56fWSt7gby18= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=nGy6V5Z3; 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="nGy6V5Z3" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B6706C2BBFC; Tue, 30 Apr 2024 11:29:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1714476596; bh=UWkDCFnZ61yO6SAwL6rskwlSmq/KozOJXKlqVHpd6JM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nGy6V5Z3pGliZg8NMojWSzXSVaHwWaXZLDaXboW82DkQk4ygPmVn4hwS5EXGLgtEv 0tsguLvGYYbI9nSDt63KEzS/b2Tntb2jLJMSkE7XQdnj9Gid+cU+6QM1ITi+hZ82N6 RbLOZUoq6iKNpp9+Td9uRrTrc4fUTyp12AS+uWtE= 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 6.1 080/110] irqchip/gic-v3-its: Prevent double free on error Date: Tue, 30 Apr 2024 12:40:49 +0200 Message-ID: <20240430103049.927206446@linuxfoundation.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240430103047.561802595@linuxfoundation.org> References: <20240430103047.561802595@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 6.1-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 @@ -4535,13 +4535,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; }