Commit fa671646 authored by Jesper Juhl's avatar Jesper Juhl Committed by Linus Torvalds

[PATCH] kfree cleanup: drivers/mtd

This is the drivers/mtd part of the big kfree cleanup patch.

Remove pointless checks for NULL prior to calling kfree() in drivers/mtd/.
Signed-off-by: default avatarJesper Juhl <jesper.juhl@gmail.com>
Cc: David Woodhouse <dwmw2@infradead.org>
Acked-by: default avatarJoern Engel <joern@wohnheim.fh-wedel.de>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent c9475cb0
...@@ -455,7 +455,6 @@ static struct mtd_info *cfi_intelext_setup(struct mtd_info *mtd) ...@@ -455,7 +455,6 @@ static struct mtd_info *cfi_intelext_setup(struct mtd_info *mtd)
setup_err: setup_err:
if(mtd) { if(mtd) {
if(mtd->eraseregions)
kfree(mtd->eraseregions); kfree(mtd->eraseregions);
kfree(mtd); kfree(mtd);
} }
......
...@@ -378,7 +378,6 @@ static struct mtd_info *cfi_amdstd_setup(struct mtd_info *mtd) ...@@ -378,7 +378,6 @@ static struct mtd_info *cfi_amdstd_setup(struct mtd_info *mtd)
setup_err: setup_err:
if(mtd) { if(mtd) {
if(mtd->eraseregions)
kfree(mtd->eraseregions); kfree(mtd->eraseregions);
kfree(mtd); kfree(mtd);
} }
...@@ -1742,6 +1741,7 @@ static void cfi_amdstd_destroy(struct mtd_info *mtd) ...@@ -1742,6 +1741,7 @@ static void cfi_amdstd_destroy(struct mtd_info *mtd)
{ {
struct map_info *map = mtd->priv; struct map_info *map = mtd->priv;
struct cfi_private *cfi = map->fldrv_priv; struct cfi_private *cfi = map->fldrv_priv;
kfree(cfi->cmdset_priv); kfree(cfi->cmdset_priv);
kfree(cfi->cfiq); kfree(cfi->cfiq);
kfree(cfi); kfree(cfi);
......
...@@ -539,11 +539,8 @@ static void free_device(struct blkmtd_dev *dev) ...@@ -539,11 +539,8 @@ static void free_device(struct blkmtd_dev *dev)
{ {
DEBUG(2, "blkmtd: free_device() dev = %p\n", dev); DEBUG(2, "blkmtd: free_device() dev = %p\n", dev);
if(dev) { if(dev) {
if(dev->mtd_info.eraseregions)
kfree(dev->mtd_info.eraseregions); kfree(dev->mtd_info.eraseregions);
if(dev->mtd_info.name)
kfree(dev->mtd_info.name); kfree(dev->mtd_info.name);
if(dev->blkdev) { if(dev->blkdev) {
invalidate_inode_pages(dev->blkdev->bd_inode->i_mapping); invalidate_inode_pages(dev->blkdev->bd_inode->i_mapping);
close_bdev_excl(dev->blkdev); close_bdev_excl(dev->blkdev);
......
...@@ -126,9 +126,7 @@ static void inftl_add_mtd(struct mtd_blktrans_ops *tr, struct mtd_info *mtd) ...@@ -126,9 +126,7 @@ static void inftl_add_mtd(struct mtd_blktrans_ops *tr, struct mtd_info *mtd)
} }
if (add_mtd_blktrans_dev(&inftl->mbd)) { if (add_mtd_blktrans_dev(&inftl->mbd)) {
if (inftl->PUtable)
kfree(inftl->PUtable); kfree(inftl->PUtable);
if (inftl->VUtable)
kfree(inftl->VUtable); kfree(inftl->VUtable);
kfree(inftl); kfree(inftl);
return; return;
...@@ -147,9 +145,7 @@ static void inftl_remove_dev(struct mtd_blktrans_dev *dev) ...@@ -147,9 +145,7 @@ static void inftl_remove_dev(struct mtd_blktrans_dev *dev)
del_mtd_blktrans_dev(dev); del_mtd_blktrans_dev(dev);
if (inftl->PUtable)
kfree(inftl->PUtable); kfree(inftl->PUtable);
if (inftl->VUtable)
kfree(inftl->VUtable); kfree(inftl->VUtable);
kfree(inftl); kfree(inftl);
} }
......
...@@ -259,9 +259,7 @@ static int __devinit amd76xrom_init_one (struct pci_dev *pdev, ...@@ -259,9 +259,7 @@ static int __devinit amd76xrom_init_one (struct pci_dev *pdev,
out: out:
/* Free any left over map structures */ /* Free any left over map structures */
if (map) {
kfree(map); kfree(map);
}
/* See if I have any map structures */ /* See if I have any map structures */
if (list_empty(&window->maps)) { if (list_empty(&window->maps)) {
amd76xrom_cleanup(window); amd76xrom_cleanup(window);
......
...@@ -104,7 +104,6 @@ static int bast_flash_remove(struct device *dev) ...@@ -104,7 +104,6 @@ static int bast_flash_remove(struct device *dev)
map_destroy(info->mtd); map_destroy(info->mtd);
} }
if (info->partitions)
kfree(info->partitions); kfree(info->partitions);
if (info->area) { if (info->area) {
......
...@@ -313,7 +313,6 @@ static void __init clps_locate_partitions(struct mtd_info *mtd) ...@@ -313,7 +313,6 @@ static void __init clps_locate_partitions(struct mtd_info *mtd)
static void __exit clps_destroy_partitions(void) static void __exit clps_destroy_partitions(void)
{ {
if (parsed_parts)
kfree(parsed_parts); kfree(parsed_parts);
} }
......
...@@ -306,9 +306,8 @@ static int __devinit ichxrom_init_one (struct pci_dev *pdev, ...@@ -306,9 +306,8 @@ static int __devinit ichxrom_init_one (struct pci_dev *pdev,
out: out:
/* Free any left over map structures */ /* Free any left over map structures */
if (map) {
kfree(map); kfree(map);
}
/* See if I have any map structures */ /* See if I have any map structures */
if (list_empty(&window->maps)) { if (list_empty(&window->maps)) {
ichxrom_cleanup(window); ichxrom_cleanup(window);
......
...@@ -148,7 +148,6 @@ static int armflash_probe(struct device *_dev) ...@@ -148,7 +148,6 @@ static int armflash_probe(struct device *_dev)
del_mtd_partitions(info->mtd); del_mtd_partitions(info->mtd);
map_destroy(info->mtd); map_destroy(info->mtd);
} }
if (info->parts)
kfree(info->parts); kfree(info->parts);
no_device: no_device:
...@@ -176,7 +175,6 @@ static int armflash_remove(struct device *_dev) ...@@ -176,7 +175,6 @@ static int armflash_remove(struct device *_dev)
del_mtd_partitions(info->mtd); del_mtd_partitions(info->mtd);
map_destroy(info->mtd); map_destroy(info->mtd);
} }
if (info->parts)
kfree(info->parts); kfree(info->parts);
iounmap(info->map.virt); iounmap(info->map.virt);
......
...@@ -431,7 +431,6 @@ static void __exit ipaq_mtd_cleanup(void) ...@@ -431,7 +431,6 @@ static void __exit ipaq_mtd_cleanup(void)
if (my_sub_mtd[i]) if (my_sub_mtd[i])
map_destroy(my_sub_mtd[i]); map_destroy(my_sub_mtd[i]);
} }
if (parsed_parts)
kfree(parsed_parts); kfree(parsed_parts);
} }
} }
......
...@@ -103,7 +103,6 @@ static void __exit cleanup_iq80310(void) ...@@ -103,7 +103,6 @@ static void __exit cleanup_iq80310(void)
if (mymtd) { if (mymtd) {
del_mtd_partitions(mymtd); del_mtd_partitions(mymtd);
map_destroy(mymtd); map_destroy(mymtd);
if (parsed_parts)
kfree(parsed_parts); kfree(parsed_parts);
} }
if (iq80310_map.virt) if (iq80310_map.virt)
......
...@@ -129,8 +129,7 @@ static int ixp2000_flash_remove(struct device *_dev) ...@@ -129,8 +129,7 @@ static int ixp2000_flash_remove(struct device *_dev)
if (info->map.map_priv_1) if (info->map.map_priv_1)
iounmap((void *) info->map.map_priv_1); iounmap((void *) info->map.map_priv_1);
if (info->partitions) { kfree(info->partitions);
kfree(info->partitions); }
if (info->res) { if (info->res) {
release_resource(info->res); release_resource(info->res);
......
...@@ -124,7 +124,6 @@ static int ixp4xx_flash_remove(struct device *_dev) ...@@ -124,7 +124,6 @@ static int ixp4xx_flash_remove(struct device *_dev)
if (info->map.map_priv_1) if (info->map.map_priv_1)
iounmap((void *) info->map.map_priv_1); iounmap((void *) info->map.map_priv_1);
if (info->partitions)
kfree(info->partitions); kfree(info->partitions);
if (info->res) { if (info->res) {
......
...@@ -158,7 +158,6 @@ static void __exit cleanup_lubbock(void) ...@@ -158,7 +158,6 @@ static void __exit cleanup_lubbock(void)
if (lubbock_maps[i].cached) if (lubbock_maps[i].cached)
iounmap(lubbock_maps[i].cached); iounmap(lubbock_maps[i].cached);
if (parsed_parts[i])
kfree(parsed_parts[i]); kfree(parsed_parts[i]);
} }
} }
......
...@@ -124,7 +124,6 @@ static void __exit omap_toto_mtd_cleanup(void) ...@@ -124,7 +124,6 @@ static void __exit omap_toto_mtd_cleanup(void)
if (flash_mtd) { if (flash_mtd) {
del_mtd_partitions(flash_mtd); del_mtd_partitions(flash_mtd);
map_destroy(flash_mtd); map_destroy(flash_mtd);
if (parsed_parts)
kfree(parsed_parts); kfree(parsed_parts);
} }
} }
......
...@@ -241,7 +241,6 @@ static void sa1100_destroy(struct sa_info *info, struct flash_platform_data *pla ...@@ -241,7 +241,6 @@ static void sa1100_destroy(struct sa_info *info, struct flash_platform_data *pla
#endif #endif
} }
if (info->parts)
kfree(info->parts); kfree(info->parts);
for (i = info->num_subdev - 1; i >= 0; i--) for (i = info->num_subdev - 1; i >= 0; i--)
......
...@@ -166,9 +166,7 @@ static void __exit uflash_cleanup(void) ...@@ -166,9 +166,7 @@ static void __exit uflash_cleanup(void)
iounmap(udev->map.virt); iounmap(udev->map.virt);
udev->map.virt = NULL; udev->map.virt = NULL;
} }
if(0 != udev->name) {
kfree(udev->name); kfree(udev->name);
}
kfree(udev); kfree(udev);
} }
} }
......
...@@ -224,10 +224,8 @@ int __init init_tqm_mtd(void) ...@@ -224,10 +224,8 @@ int __init init_tqm_mtd(void)
error_mem: error_mem:
for(idx = 0 ; idx < FLASH_BANK_MAX ; idx++) { for(idx = 0 ; idx < FLASH_BANK_MAX ; idx++) {
if(map_banks[idx] != NULL) { if(map_banks[idx] != NULL) {
if(map_banks[idx]->name != NULL) {
kfree(map_banks[idx]->name); kfree(map_banks[idx]->name);
map_banks[idx]->name = NULL; map_banks[idx]->name = NULL;
}
kfree(map_banks[idx]); kfree(map_banks[idx]);
map_banks[idx] = NULL; map_banks[idx] = NULL;
} }
......
...@@ -2676,8 +2676,7 @@ void nand_release (struct mtd_info *mtd) ...@@ -2676,8 +2676,7 @@ void nand_release (struct mtd_info *mtd)
/* Deregister the device */ /* Deregister the device */
del_mtd_device (mtd); del_mtd_device (mtd);
/* Free bad block table memory, if allocated */ /* Free bad block table memory */
if (this->bbt)
kfree (this->bbt); kfree (this->bbt);
/* Buffer allocated by nand_scan ? */ /* Buffer allocated by nand_scan ? */
if (this->options & NAND_OOBBUF_ALLOC) if (this->options & NAND_OOBBUF_ALLOC)
......
...@@ -114,9 +114,7 @@ static void nftl_add_mtd(struct mtd_blktrans_ops *tr, struct mtd_info *mtd) ...@@ -114,9 +114,7 @@ static void nftl_add_mtd(struct mtd_blktrans_ops *tr, struct mtd_info *mtd)
} }
if (add_mtd_blktrans_dev(&nftl->mbd)) { if (add_mtd_blktrans_dev(&nftl->mbd)) {
if (nftl->ReplUnitTable)
kfree(nftl->ReplUnitTable); kfree(nftl->ReplUnitTable);
if (nftl->EUNtable)
kfree(nftl->EUNtable); kfree(nftl->EUNtable);
kfree(nftl); kfree(nftl);
return; return;
...@@ -133,9 +131,7 @@ static void nftl_remove_dev(struct mtd_blktrans_dev *dev) ...@@ -133,9 +131,7 @@ static void nftl_remove_dev(struct mtd_blktrans_dev *dev)
DEBUG(MTD_DEBUG_LEVEL1, "NFTL: remove_dev (i=%d)\n", dev->devnum); DEBUG(MTD_DEBUG_LEVEL1, "NFTL: remove_dev (i=%d)\n", dev->devnum);
del_mtd_blktrans_dev(dev); del_mtd_blktrans_dev(dev);
if (nftl->ReplUnitTable)
kfree(nftl->ReplUnitTable); kfree(nftl->ReplUnitTable);
if (nftl->EUNtable)
kfree(nftl->EUNtable); kfree(nftl->EUNtable);
kfree(nftl); kfree(nftl);
} }
......
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