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 2546B12C461; Tue, 30 Apr 2024 10:45:25 +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=1714473925; cv=none; b=u3lbgy5tUrviwE10KWup+V1Ry7oup1CL7rQ4gvSULesoRgA3bWxtpYCpYHAuR+JqC8u6e6LOgpl+gVnvi9+7MKwsJkchlg+VeIsyiWq/TdqVYqeckuyzWwWchglhfGs6LlGS51K4waky7s96aMfBTLOjkDewclfP9zilJmOyjQw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714473925; c=relaxed/simple; bh=M3fxBjXJyAFB4yJUrUgN/SzcM3dkofxrZdHMp8l5qek=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=c+KcnXq7oPLIkayJBXhZZvnetaJDk8CW7qYKc8h7N/0k4BSOOHhdbwgqFiouEpCGMTVCwm4e+NHxHZFUx/vk746Cr1DiTayhFUjr9iH83Nlucw+WptlHjajs5LxKAVIglmgM2b/TKTlDa47kYwGRYAwExZ7iNHriiOUgtH9rHIk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=cRXZJcVl; 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="cRXZJcVl" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9B51EC2BBFC; Tue, 30 Apr 2024 10:45:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1714473925; bh=M3fxBjXJyAFB4yJUrUgN/SzcM3dkofxrZdHMp8l5qek=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cRXZJcVl3TBhZBMTEJNa0K760tHtEvRVWRWR7ZHCWWJECDPDqPSukdWktqkb6QMuQ I7Iqj1Sy6sNqtTfhs9DdL5z/OPrpREWIEirSuPcglt9FppuMWNzWH5GFm9H8f2XW7p 4GyCt5ZpBSbcjY6cWSHumD0PyP4LACOBnpVhc2cY= 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 4.19 64/77] irqchip/gic-v3-its: Prevent double free on error Date: Tue, 30 Apr 2024 12:39:43 +0200 Message-ID: <20240430103043.027960218@linuxfoundation.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240430103041.111219002@linuxfoundation.org> References: <20240430103041.111219002@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 4.19-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 @@ -2994,13 +2994,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; }