omap iommu: Fix Memory leak
authorSatish <x0124230@ti.com>
Wed, 9 Jun 2010 10:21:27 +0000 (13:21 +0300)
committerTony Lindgren <tony@atomide.com>
Wed, 9 Jun 2010 10:21:27 +0000 (13:21 +0300)
The memory allocated for sgt structure is not freed on error
when sg_alloc_table is called in sgtable_alloc().

Signed-off-by: Satish Kumar <x0124230@ti.com>
Signed-off-by: Manjunatha GK <manjugk@ti.com>
Cc: Vimal Singh <vimal.newwork@gmail.com>
Signed-off-by: Hiroshi DOYU <Hiroshi.DOYU@nokia.com>
Signed-off-by: Tony Lindgen <tony@atomide.com>
arch/arm/plat-omap/iovmm.c

index e43983ba59c5eb77ac61caa3a2ebaca83b50416c..8ce0de247c71fc7b59863a6722036ef011238240 100644 (file)
@@ -140,8 +140,10 @@ static struct sg_table *sgtable_alloc(const size_t bytes, u32 flags)
                return ERR_PTR(-ENOMEM);
 
        err = sg_alloc_table(sgt, nr_entries, GFP_KERNEL);
-       if (err)
+       if (err) {
+               kfree(sgt);
                return ERR_PTR(err);
+       }
 
        pr_debug("%s: sgt:%p(%d entries)\n", __func__, sgt, nr_entries);