Subject: [PATCH] powerpc: kmalloc failure ignored in vio_build_iommu_table()

From: Roel Kluin <[email-masked]>
Date: Wed, 09 Sep 2009 17:02:24 +0200

Prevent NULL dereference if kmalloc() fails.

Signed-off-by: Roel Kluin <[email-masked]>
---
Found with sed: http://kernelnewbies.org/roelkluin

diff --git a/arch/powerpc/kernel/vio.c b/arch/powerpc/kernel/vio.c
index 819e59f..1f5266f 100644
--- a/arch/powerpc/kernel/vio.c
+++ b/arch/powerpc/kernel/vio.c
@@ -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);