]> git.hungrycats.org Git - linux/commitdiff
[PATCH] fix memleak in mtd/chips/cfi_cmdset_0020.c
authorAndrew Morton <akpm@osdl.org>
Wed, 1 Oct 2003 17:58:31 +0000 (10:58 -0700)
committerLinus Torvalds <torvalds@home.osdl.org>
Wed, 1 Oct 2003 17:58:31 +0000 (10:58 -0700)
From: Felipe W Damasio <felipewd@terra.com.br>

If other kmallocs failed after successfully allocating a "struct mtd_info",
it should be freed before returning NULL.

drivers/mtd/chips/cfi_cmdset_0020.c

index 943e52b368d51bd2377abfc77ce0a567e33a40f2..e481567c462ff944f0456791fee724b177d49d04 100644 (file)
@@ -208,6 +208,7 @@ static struct mtd_info *cfi_staa_setup(struct map_info *map)
        if (!mtd->eraseregions) { 
                printk(KERN_ERR "Failed to allocate memory for MTD erase region info\n");
                kfree(cfi->cmdset_priv);
+               kfree(mtd);
                return NULL;
        }
        
@@ -232,6 +233,7 @@ static struct mtd_info *cfi_staa_setup(struct map_info *map)
                        printk(KERN_WARNING "Sum of regions (%lx) != total size of set of interleaved chips (%lx)\n", offset, devsize);
                        kfree(mtd->eraseregions);
                        kfree(cfi->cmdset_priv);
+                       kfree(mtd);
                        return NULL;
                }