Commit 6e930045 authored by Joerg Roedel's avatar Joerg Roedel
Browse files

iommu/amd: Fix double free of mem-region in error-path



When ioremap_nocache fails in iommu initialization the code
calls release_mem_region immediatly. But the function is
called again when the propagates into the upper init
functions leading to a double-free. Fix that.

Reported-by: default avatarDon Dutile <ddutile@redhat.com>
Signed-off-by: default avatarJoerg Roedel <joerg.roedel@amd.com>
parent 8704a1ba
Loading
Loading
Loading
Loading
+1 −9
Original line number Original line Diff line number Diff line
@@ -358,8 +358,6 @@ static void iommu_disable(struct amd_iommu *iommu)
 */
 */
static u8 * __init iommu_map_mmio_space(u64 address)
static u8 * __init iommu_map_mmio_space(u64 address)
{
{
	u8 *ret;

	if (!request_mem_region(address, MMIO_REGION_LENGTH, "amd_iommu")) {
	if (!request_mem_region(address, MMIO_REGION_LENGTH, "amd_iommu")) {
		pr_err("AMD-Vi: Can not reserve memory region %llx for mmio\n",
		pr_err("AMD-Vi: Can not reserve memory region %llx for mmio\n",
			address);
			address);
@@ -367,13 +365,7 @@ static u8 * __init iommu_map_mmio_space(u64 address)
		return NULL;
		return NULL;
	}
	}


	ret = ioremap_nocache(address, MMIO_REGION_LENGTH);
	return ioremap_nocache(address, MMIO_REGION_LENGTH);
	if (ret != NULL)
		return ret;

	release_mem_region(address, MMIO_REGION_LENGTH);

	return NULL;
}
}


static void __init iommu_unmap_mmio_space(struct amd_iommu *iommu)
static void __init iommu_unmap_mmio_space(struct amd_iommu *iommu)