Skip to contentSkip to conversation

powerpc: kmalloc failure ignored in vio_build_iommu_table()

PATCH New Roel Kluin 1 participant 1 message Sep 9, 2009 PowerPC

lore
Share & tools
lore

Roel Kluin

author
#0 lore raw

PATCH 1/1 powerpc: kmalloc failure ignored in vio_build_iommu_table()

Prevent NULL dereference if kmalloc() fails.

---
Found with sed: http://kernelnewbies.org/roelkluin

arch/powerpc/kernel/vio.c +2 -0
index 819e59f..1f5266f 100644
@@ -1054,6 +1054,8 @@ static struct iommu_table *vio_build_iommu_table(struct vio_dev *dev)
 		return NULL;
 
 	tbl = kmalloc(sizeof(*tbl), GFP_KERNEL);
+	if (tbl == NULL)
+		return NULL;
 
 	of_parse_dma_window(dev->dev.archdata.of_node, dma_window,
 			    &tbl->it_index, &offset, &size);