Skip to contentSkip to conversation

iommu/vt-d: Fix leak in intel_pasid_alloc_table on error path

PATCH Applied Eric Auger 2 participants 2 messages Apr 30, 2019 – May 3, 2019 IOMMU

lore
Share & tools
lore

Eric Auger

author
#0 lore raw

PATCH 1/1 iommu/vt-d: Fix leak in intel_pasid_alloc_table on error path

If alloc_pages_node() fails, pasid_table is leaked. Free it.

Fixes cc580e41260db ("iommu/vt-d: Per PCI device pasid table interfaces")
---
 drivers/iommu/intel-pasid.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/iommu/intel-pasid.c +3 -1
index 03b12d2ee213..2fefeafda437 100644
@@ -154,8 +154,10 @@ int intel_pasid_alloc_table(struct device *dev)
 	order = size ? get_order(size) : 0;
 	pages = alloc_pages_node(info->iommu->node,
 				 GFP_KERNEL | __GFP_ZERO, order);
-	if (!pages)
+	if (!pages) {
+		kfree(pasid_table);
 		return -ENOMEM;
+	}
 
 	pasid_table->table = page_address(pages);
 	pasid_table->order = order;
Signature · 1 line
2.20.1
maintainer Applied
#1 lore raw
Quoted 8 lines · Eric Auger

If alloc_pages_node() fails, pasid_table is leaked. Free it.

Fixes cc580e41260db ("iommu/vt-d: Per PCI device pasid table interfaces")
---
 drivers/iommu/intel-pasid.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Applied, thanks.