Commit ff2de3b3 authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] fix memleak in mtd/chips/cfi_cmdset_0020.c

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.
parent dc5f46be
......@@ -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;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment