mtd/drivers/mtd/chips cfi_cmdset_0002.c,1.60,1.61
spse at infradead.org
spse at infradead.org
Sun Nov 17 08:10:37 EST 2002
Update of /home/cvs/mtd/drivers/mtd/chips
In directory phoenix.infradead.org:/tmp/cvs-serv8831
Modified Files:
cfi_cmdset_0002.c
Log Message:
cfi_cmdset_0002(): remove extraneous MOD_INC_USE_COUNT
cfi_amdstd_setup(): fix up memleaks in the init failpath
cfi_amdstd_destroy(): free cfi->cmdset_priv and mtd->eraseregions
Index: cfi_cmdset_0002.c
===================================================================
RCS file: /home/cvs/mtd/drivers/mtd/chips/cfi_cmdset_0002.c,v
retrieving revision 1.60
retrieving revision 1.61
diff -u -r1.60 -r1.61
--- cfi_cmdset_0002.c 15 Oct 2002 15:09:26 -0000 1.60
+++ cfi_cmdset_0002.c 17 Nov 2002 13:10:34 -0000 1.61
@@ -138,7 +138,6 @@
}
map->fldrv = &cfi_amdstd_chipdrv;
- MOD_INC_USE_COUNT;
cfi_send_gen_cmd(0xf0, 0x55, base, map, cfi, cfi->device_type, NULL);
return cfi_amdstd_setup(map);
@@ -156,8 +155,7 @@
if (!mtd) {
printk(KERN_WARNING "Failed to allocate memory for MTD device\n");
- kfree(cfi->cmdset_priv);
- return NULL;
+ goto setup_err;
}
memset(mtd, 0, sizeof(*mtd));
@@ -177,8 +175,7 @@
mtd->eraseregions = kmalloc(sizeof(struct mtd_erase_region_info) * mtd->numeraseregions, GFP_KERNEL);
if (!mtd->eraseregions) {
printk(KERN_WARNING "Failed to allocate memory for MTD erase region info\n");
- kfree(cfi->cmdset_priv);
- return NULL;
+ goto setup_err;
}
for (i=0; i<cfi->cfiq->NumEraseRegions; i++) {
@@ -199,9 +196,7 @@
if (offset != devsize) {
/* Argh */
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);
- return NULL;
+ goto setup_err;
}
#if 0
// debug
@@ -234,9 +229,7 @@
default:
printk(KERN_WARNING "Unsupported buswidth\n");
- kfree(mtd);
- kfree(cfi->cmdset_priv);
- return NULL;
+ goto setup_err;
break;
}
if (cfi->fast_prog) {
@@ -275,6 +268,16 @@
mtd->name = map->name;
MOD_INC_USE_COUNT;
return mtd;
+
+ setup_err:
+ if(mtd) {
+ if(mtd->eraseregions)
+ kfree(mtd->eraseregions);
+ kfree(mtd);
+ }
+ kfree(cfi->cmdset_priv);
+ kfree(cfi->cfiq);
+ return NULL;
}
static inline int do_read_onechip(struct map_info *map, struct flchip *chip, loff_t adr, size_t len, u_char *buf)
@@ -1281,7 +1284,9 @@
struct map_info *map = mtd->priv;
struct cfi_private *cfi = map->fldrv_priv;
kfree(cfi->cmdset_priv);
+ kfree(cfi->cfiq);
kfree(cfi);
+ kfree(mtd->eraseregions);
}
static char im_name[]="cfi_cmdset_0002";
More information about the linux-mtd-cvs
mailing list