2014-02-11 02:13:46

by Zhouyi Zhou

[permalink] [raw]
Subject: [PATCH] IOMMU: iommu module do not check NULL return of kmem_cache_zalloc

From: Zhouyi Zhou <[email protected]>

The function iopte_alloc do not check NULL return of kmem_cache_zalloc,
call iopte_free with argument 0 will panic.

Signed-off-by: Zhouyi Zhou <[email protected]>
---
drivers/iommu/omap-iommu.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/iommu/omap-iommu.c b/drivers/iommu/omap-iommu.c
index bcd78a7..5155714 100644
--- a/drivers/iommu/omap-iommu.c
+++ b/drivers/iommu/omap-iommu.c
@@ -551,7 +551,8 @@ static u32 *iopte_alloc(struct omap_iommu *obj, u32 *iopgd, u32 da)
dev_vdbg(obj->dev, "%s: a new pte:%p\n", __func__, iopte);
} else {
/* We raced, free the reduniovant table */
- iopte_free(iopte);
+ if (iopte)
+ iopte_free(iopte);
}

pte_ready:
--
1.7.10.4