Skip to contentSkip to conversation

iommu/amd: use after free in get_irq_table()

PATCH In review Dan Carpenter 2 participants 2 messages Oct 2, 2012 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 iommu/amd: use after free in get_irq_table()

We should return NULL on error instead of the freed pointer.

drivers/iommu/amd_iommu.c +1 -0
index e78b8a4..a636d68 100644
@@ -3867,6 +3867,7 @@ static struct irq_remap_table *get_irq_table(u16 devid, bool ioapic)
 	table->table = kmem_cache_alloc(amd_iommu_irq_cache, GFP_ATOMIC);
 	if (!table->table) {
 		kfree(table);
+		table = NULL;
 		goto out;
 	}
 
#2 lore raw
In reply to a message not in the archive
Quoted 9 lines · Dan Carpenter

We should return NULL on error instead of the freed pointer.

drivers/iommu/amd_iommu.c +0 -0
index e78b8a4..a636d68 100644

drivers/iommu/amd_iommu.c static struct irq_remap_table *get_irq_table(u16 devid, bool ioapic) · line 3872

Quoted 6 lines
drivers/iommu/amd_iommu.c +1 -0
@@ -3867,6 +3867,7 @@ static struct irq_remap_table *get_irq_table(u16 devid, bool ioapic)
 	table->table = kmem_cache_alloc(amd_iommu_irq_cache, GFP_ATOMIC);
 	if (!table->table) {
 		kfree(table);
+		table = NULL;
 		goto out;
 	}

Good catch. Thanks, applied.

Signature · 5 lines
AMD Operating System Research Center

Advanced Micro Devices GmbH Einsteinring 24 85609 Dornach
General Managers: Alberto Bozzo
Registration: Dornach, Landkr. Muenchen; Registerger. Muenchen, HRB Nr. 43632