IOMMU: iommu module do not check NULL return of kmem_cache_zalloc
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.
Signed-off-by Zhouyi Zhou <yizhouzhou-6xnC4QlcT6v/[email protected]>
--- drivers/iommu/omap-iommu.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
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); } pte_ready:
Signature · 1 line
1.7.10.4
Joerg Roedel
maintainerQuoted 15 lines · Zhouyi Zhou
From: Zhouyi Zhou <yizhouzhou-6xnC4QlcT6v/[email protected]>
The function
iopte_allocdo not check NULL return ofkmem_cache_zalloc, calliopte_freewith argument 0 will panic.Signed-off-by Zhouyi Zhou <yizhouzhou-6xnC4QlcT6v/[email protected]>--- drivers/iommu/omap-iommu.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/iommu/omap-iommu.c +0
-0
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