Skip to contentSkip to conversation

IOMMU: iommu module do not check NULL return of kmem_cache_zalloc

PATCH In review Zhouyi Zhou 2 participants 2 messages Feb 11, 2014 – Mar 4, 2014 IOMMU

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 IOMMU: iommu module do not check NULL return of kmem_cache_zalloc

From: Zhouyi Zhou <yizhouzhou-6xnC4QlcT6v/[email protected]>

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

---
 drivers/iommu/omap-iommu.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/iommu/omap-iommu.c +2 -1
index bcd78a7..5155714 100644
@@ -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:
Signature · 1 line
1.7.10.4
maintainer
#1 lore raw
Quoted 15 lines · Zhouyi Zhou

From: Zhouyi Zhou <yizhouzhou-6xnC4QlcT6v/[email protected]>

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

---
 drivers/iommu/omap-iommu.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/iommu/omap-iommu.c +0 -0
index bcd78a7..5155714 100644

drivers/iommu/omap-iommu.c static u32 *iopte_alloc(struct omap_iommu *obj, u32 *iopgd, u32 da) · line 555

Quoted 6 lines
drivers/iommu/omap-iommu.c +2 -1
@@ -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);

Isn't it better to put the check into iopte_free?

Joerg