mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-07-21 22:47:51 -04:00
mtd: cfi: Use common error handling code in two functions
Use additional labels so that a bit of exception handling can be better reused at the end of two function implementations. This issue was detected by using the Coccinelle software. Signed-off-by: Markus Elfring <elfring@users.sourceforge.net> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
This commit is contained in:
committed by
Miquel Raynal
parent
4fe97a54da
commit
cf4ff717af
@@ -661,8 +661,7 @@ struct mtd_info *cfi_cmdset_0002(struct map_info *map, int primary)
|
||||
extp->MajorVersion, extp->MinorVersion,
|
||||
extp->MajorVersion, extp->MinorVersion);
|
||||
kfree(extp);
|
||||
kfree(mtd);
|
||||
return NULL;
|
||||
goto free_mtd;
|
||||
}
|
||||
|
||||
printk(KERN_INFO " Amd/Fujitsu Extended Query version %c.%c.\n",
|
||||
@@ -714,10 +713,8 @@ struct mtd_info *cfi_cmdset_0002(struct map_info *map, int primary)
|
||||
}
|
||||
cfi_fixup(mtd, cfi_nopri_fixup_table);
|
||||
|
||||
if (!cfi->addr_unlock1 || !cfi->addr_unlock2) {
|
||||
kfree(mtd);
|
||||
return NULL;
|
||||
}
|
||||
if (!cfi->addr_unlock1 || !cfi->addr_unlock2)
|
||||
goto free_mtd;
|
||||
|
||||
} /* CFI mode */
|
||||
else if (cfi->cfi_mode == CFI_MODE_JEDEC) {
|
||||
@@ -755,6 +752,10 @@ struct mtd_info *cfi_cmdset_0002(struct map_info *map, int primary)
|
||||
map->fldrv = &cfi_amdstd_chipdrv;
|
||||
|
||||
return cfi_amdstd_setup(mtd);
|
||||
|
||||
free_mtd:
|
||||
kfree(mtd);
|
||||
return NULL;
|
||||
}
|
||||
struct mtd_info *cfi_cmdset_0006(struct map_info *map, int primary) __attribute__((alias("cfi_cmdset_0002")));
|
||||
struct mtd_info *cfi_cmdset_0701(struct map_info *map, int primary) __attribute__((alias("cfi_cmdset_0002")));
|
||||
|
||||
@@ -174,11 +174,8 @@ static struct mtd_info *cfi_staa_setup(struct map_info *map)
|
||||
|
||||
mtd = kzalloc_obj(*mtd);
|
||||
//printk(KERN_DEBUG "number of CFI chips: %d\n", cfi->numchips);
|
||||
|
||||
if (!mtd) {
|
||||
kfree(cfi->cmdset_priv);
|
||||
return NULL;
|
||||
}
|
||||
if (!mtd)
|
||||
goto free_cmdset_priv;
|
||||
|
||||
mtd->priv = map;
|
||||
mtd->type = MTD_NORFLASH;
|
||||
@@ -187,11 +184,8 @@ static struct mtd_info *cfi_staa_setup(struct map_info *map)
|
||||
mtd->numeraseregions = cfi->cfiq->NumEraseRegions * cfi->numchips;
|
||||
mtd->eraseregions = kmalloc_objs(struct mtd_erase_region_info,
|
||||
mtd->numeraseregions);
|
||||
if (!mtd->eraseregions) {
|
||||
kfree(cfi->cmdset_priv);
|
||||
kfree(mtd);
|
||||
return NULL;
|
||||
}
|
||||
if (!mtd->eraseregions)
|
||||
goto free_mtd;
|
||||
|
||||
for (i=0; i<cfi->cfiq->NumEraseRegions; i++) {
|
||||
unsigned long ernum, ersize;
|
||||
@@ -213,9 +207,7 @@ static struct mtd_info *cfi_staa_setup(struct map_info *map)
|
||||
/* 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);
|
||||
kfree(mtd);
|
||||
return NULL;
|
||||
goto free_mtd;
|
||||
}
|
||||
|
||||
for (i=0; i<mtd->numeraseregions;i++){
|
||||
@@ -242,6 +234,12 @@ static struct mtd_info *cfi_staa_setup(struct map_info *map)
|
||||
__module_get(THIS_MODULE);
|
||||
mtd->name = map->name;
|
||||
return mtd;
|
||||
|
||||
free_mtd:
|
||||
kfree(mtd);
|
||||
free_cmdset_priv:
|
||||
kfree(cfi->cmdset_priv);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user