[PATCH] kfree cleanup: drivers/mtd
authorJesper Juhl <jesper.juhl@gmail.com>
Mon, 7 Nov 2005 09:01:27 +0000 (01:01 -0800)
committerLinus Torvalds <torvalds@g5.osdl.org>
Mon, 7 Nov 2005 15:54:02 +0000 (07:54 -0800)
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: Jesper Juhl <jesper.juhl@gmail.com>
Cc: David Woodhouse <dwmw2@infradead.org>
Acked-by: Joern Engel <joern@wohnheim.fh-wedel.de>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
20 files changed:
drivers/mtd/chips/cfi_cmdset_0001.c
drivers/mtd/chips/cfi_cmdset_0002.c
drivers/mtd/devices/blkmtd.c
drivers/mtd/inftlcore.c
drivers/mtd/maps/amd76xrom.c
drivers/mtd/maps/bast-flash.c
drivers/mtd/maps/ceiva.c
drivers/mtd/maps/ichxrom.c
drivers/mtd/maps/integrator-flash.c
drivers/mtd/maps/ipaq-flash.c
drivers/mtd/maps/iq80310.c
drivers/mtd/maps/ixp2000.c
drivers/mtd/maps/ixp4xx.c
drivers/mtd/maps/lubbock-flash.c
drivers/mtd/maps/omap-toto-flash.c
drivers/mtd/maps/sa1100-flash.c
drivers/mtd/maps/sun_uflash.c
drivers/mtd/maps/tqm8xxl.c
drivers/mtd/nand/nand_base.c
drivers/mtd/nftlcore.c

index 0cfcd88468e0ed3c2db5da780bc3d7e428c3ab3c..c3fc9b2f21fbd5988a39dd2c9c0f12d0fd69190f 100644 (file)
@@ -455,8 +455,7 @@ static struct mtd_info *cfi_intelext_setup(struct mtd_info *mtd)
 
  setup_err:
        if(mtd) {
-               if(mtd->eraseregions)
-                       kfree(mtd->eraseregions);
+               kfree(mtd->eraseregions);
                kfree(mtd);
        }
        kfree(cfi->cmdset_priv);
index 8505f118f2dbfcd8d7275c3cb1af5292eaaaca0d..0e6475050da91b90c47a78c8d6532395c55c482d 100644 (file)
@@ -378,8 +378,7 @@ static struct mtd_info *cfi_amdstd_setup(struct mtd_info *mtd)
 
  setup_err:
        if(mtd) {
-               if(mtd->eraseregions)
-                       kfree(mtd->eraseregions);
+               kfree(mtd->eraseregions);
                kfree(mtd);
        }
        kfree(cfi->cmdset_priv);
@@ -1742,6 +1741,7 @@ static void cfi_amdstd_destroy(struct mtd_info *mtd)
 {
        struct map_info *map = mtd->priv;
        struct cfi_private *cfi = map->fldrv_priv;
+
        kfree(cfi->cmdset_priv);
        kfree(cfi->cfiq);
        kfree(cfi);
index 662e807801ed046e71a99ad8b50f781bc14f1fee..59a29e616a226f82112851ef76ae8a57ca1db012 100644 (file)
@@ -539,11 +539,8 @@ static void free_device(struct blkmtd_dev *dev)
 {
        DEBUG(2, "blkmtd: free_device() dev = %p\n", dev);
        if(dev) {
-               if(dev->mtd_info.eraseregions)
-                       kfree(dev->mtd_info.eraseregions);
-               if(dev->mtd_info.name)
-                       kfree(dev->mtd_info.name);
-
+               kfree(dev->mtd_info.eraseregions);
+               kfree(dev->mtd_info.name);
                if(dev->blkdev) {
                        invalidate_inode_pages(dev->blkdev->bd_inode->i_mapping);
                        close_bdev_excl(dev->blkdev);
index 39eb53f6551f0d96943539ce0ce0a41aba1dc22f..8db65bf029ea6db3ed59f30a568d5434e1b8c067 100644 (file)
@@ -126,10 +126,8 @@ static void inftl_add_mtd(struct mtd_blktrans_ops *tr, struct mtd_info *mtd)
        }
 
        if (add_mtd_blktrans_dev(&inftl->mbd)) {
-               if (inftl->PUtable)
-                       kfree(inftl->PUtable);
-               if (inftl->VUtable)
-                       kfree(inftl->VUtable);
+               kfree(inftl->PUtable);
+               kfree(inftl->VUtable);
                kfree(inftl);
                return;
        }
@@ -147,10 +145,8 @@ static void inftl_remove_dev(struct mtd_blktrans_dev *dev)
 
        del_mtd_blktrans_dev(dev);
 
-       if (inftl->PUtable)
-               kfree(inftl->PUtable);
-       if (inftl->VUtable)
-               kfree(inftl->VUtable);
+       kfree(inftl->PUtable);
+       kfree(inftl->VUtable);
        kfree(inftl);
 }
 
index e8a900a77685e4bb024a3c510a2b3e5dc3d11c1b..9a64149f431d2a547383bd97b1861e81fafd2596 100644 (file)
@@ -259,9 +259,7 @@ static int __devinit amd76xrom_init_one (struct pci_dev *pdev,
 
  out:
        /* Free any left over map structures */
-       if (map) {
-               kfree(map);
-       }
+       kfree(map);
        /* See if I have any map structures */
        if (list_empty(&window->maps)) {
                amd76xrom_cleanup(window);
index bfe994e59265d57772da814b0b08eab199e2e793..8c19d722ac796178c9d0cda7ecd3de29c8223927 100644 (file)
@@ -104,8 +104,7 @@ static int bast_flash_remove(struct device *dev)
                map_destroy(info->mtd);
        }
 
-       if (info->partitions)
-               kfree(info->partitions);
+       kfree(info->partitions);
 
        if (info->area) {
                release_resource(info->area);
index c68b31dc7e6d4979c363a8ac1e32bb0abba09f5b..5a95ab370a970cf6150d857de460a02bfeba29df 100644 (file)
@@ -313,8 +313,7 @@ static void __init clps_locate_partitions(struct mtd_info *mtd)
 
 static void __exit clps_destroy_partitions(void)
 {
-       if (parsed_parts)
-               kfree(parsed_parts);
+       kfree(parsed_parts);
 }
 
 static struct mtd_info *mymtd;
index e505207cd4892918b27c59a3ccc2f00afc0c3c59..c5e2111ba146df5535e0b90f451cc5c55d99ac63 100644 (file)
@@ -306,9 +306,8 @@ static int __devinit ichxrom_init_one (struct pci_dev *pdev,
 
  out:
        /* Free any left over map structures */
-       if (map) {
-               kfree(map);
-       }
+       kfree(map);
+
        /* See if I have any map structures */
        if (list_empty(&window->maps)) {
                ichxrom_cleanup(window);
index d14a0185b8f419f97d14595caee88803c64769d9..93f50d6d5488817cd4d2af10072a7acddd6a12a2 100644 (file)
@@ -148,8 +148,7 @@ static int armflash_probe(struct device *_dev)
                        del_mtd_partitions(info->mtd);
                        map_destroy(info->mtd);
                }
-               if (info->parts)
-                       kfree(info->parts);
+               kfree(info->parts);
 
  no_device:
                iounmap(base);
@@ -176,8 +175,7 @@ static int armflash_remove(struct device *_dev)
                        del_mtd_partitions(info->mtd);
                        map_destroy(info->mtd);
                }
-               if (info->parts)
-                       kfree(info->parts);
+               kfree(info->parts);
 
                iounmap(info->map.virt);
                release_resource(info->res);
index 712401810841bf1f1d5358b12108ddffac8affbf..70b0e0b82c34f8e7384b2fb0bae3ea51503dc10d 100644 (file)
@@ -431,8 +431,7 @@ static void __exit ipaq_mtd_cleanup(void)
                                if (my_sub_mtd[i])
                                        map_destroy(my_sub_mtd[i]);
                        }
-               if (parsed_parts)
-                       kfree(parsed_parts);
+               kfree(parsed_parts);
        }
 }
 
index 558d014e7acc0365adb8b8d2bb3ec502bf73ca0b..2e7577492a2c3602b135386f0ac0f4b6d122214d 100644 (file)
@@ -103,8 +103,7 @@ static void __exit cleanup_iq80310(void)
        if (mymtd) {
                del_mtd_partitions(mymtd);
                map_destroy(mymtd);
-               if (parsed_parts)
-                       kfree(parsed_parts);
+               kfree(parsed_parts);
        }
        if (iq80310_map.virt)
                iounmap((void *)iq80310_map.virt);
index 00b9f67580f1566550950327479fd59af1ca2a33..6f36497022d19bed60f57e78bd8882bf21b7dedb 100644 (file)
@@ -129,8 +129,7 @@ static int ixp2000_flash_remove(struct device *_dev)
        if (info->map.map_priv_1)
                iounmap((void *) info->map.map_priv_1);
 
-       if (info->partitions) {
-               kfree(info->partitions); }
+       kfree(info->partitions);
 
        if (info->res) {
                release_resource(info->res);
index 733a9297a56263eda2c49bfe7db2545f86ed78d6..0d87c02dee046f32070427b8e743ac550fa1f8ed 100644 (file)
@@ -124,8 +124,7 @@ static int ixp4xx_flash_remove(struct device *_dev)
        if (info->map.map_priv_1)
                iounmap((void *) info->map.map_priv_1);
 
-       if (info->partitions)
-               kfree(info->partitions);
+       kfree(info->partitions);
 
        if (info->res) {
                release_resource(info->res);
index 2337e0c4675061419bb9ddc6f64c4f7ff9f40378..2b4c5058787d76426b536d304374cb82ae92b82d 100644 (file)
@@ -158,8 +158,7 @@ static void __exit cleanup_lubbock(void)
                if (lubbock_maps[i].cached)
                        iounmap(lubbock_maps[i].cached);
 
-               if (parsed_parts[i])
-                       kfree(parsed_parts[i]);
+               kfree(parsed_parts[i]);
        }
 }
 
index da36e8dddd17e9833d222d108bb20fdabb53a4e3..763304154a923364151b7b4b789bf7db2e0ebbff 100644 (file)
@@ -124,8 +124,7 @@ static void  __exit omap_toto_mtd_cleanup(void)
        if (flash_mtd) {
                del_mtd_partitions(flash_mtd);
                map_destroy(flash_mtd);
-               if (parsed_parts)
-                       kfree(parsed_parts);
+               kfree(parsed_parts);
        }
 }
 
index c8d0da19d897e461a18efaace5076bfc12111d59..a31f6ee8a4be5834d5d2f7ff9b583c236ba121f1 100644 (file)
@@ -241,8 +241,7 @@ static void sa1100_destroy(struct sa_info *info, struct flash_platform_data *pla
 #endif
        }
 
-       if (info->parts)
-               kfree(info->parts);
+       kfree(info->parts);
 
        for (i = info->num_subdev - 1; i >= 0; i--)
                sa1100_destroy_subdev(&info->subdev[i]);
index 29091d10030a091651c935f6126221d1de92ff8e..1355c28f90a4d7432a59171a9622dfc710a92dea 100644 (file)
@@ -166,9 +166,7 @@ static void __exit uflash_cleanup(void)
                        iounmap(udev->map.virt);
                        udev->map.virt = NULL;
                }
-               if(0 != udev->name) {
-                       kfree(udev->name);
-               }
+               kfree(udev->name);
                kfree(udev);
        }       
 }
index 4e28b977f224120db3c5dc5d278c3593081accfb..0aca8179f27f676f022a6efb5eed81cd9a9412aa 100644 (file)
@@ -224,10 +224,8 @@ int __init init_tqm_mtd(void)
 error_mem:
        for(idx = 0 ; idx < FLASH_BANK_MAX ; idx++) {
                if(map_banks[idx] != NULL) {
-                       if(map_banks[idx]->name != NULL) {
-                               kfree(map_banks[idx]->name);
-                               map_banks[idx]->name = NULL;
-                       }
+                       kfree(map_banks[idx]->name);
+                       map_banks[idx]->name = NULL;
                        kfree(map_banks[idx]);
                        map_banks[idx] = NULL;
                }
index 04e54318bc6a603f2c44b32e3b2f8b5b260a64dc..8e78d7b96a5671af16033227e4582e694e502438 100644 (file)
@@ -2676,9 +2676,8 @@ void nand_release (struct mtd_info *mtd)
        /* Deregister the device */
        del_mtd_device (mtd);
 
-       /* Free bad block table memory, if allocated */
-       if (this->bbt)
-               kfree (this->bbt);
+       /* Free bad block table memory */
+       kfree (this->bbt);
        /* Buffer allocated by nand_scan ? */
        if (this->options & NAND_OOBBUF_ALLOC)
                kfree (this->oob_buf);
index b2014043634fc5eb842516ad1b75ebe0ed682f7b..062ff3877536066e04a56bdd2bac8d0a3b0829ff 100644 (file)
@@ -114,10 +114,8 @@ static void nftl_add_mtd(struct mtd_blktrans_ops *tr, struct mtd_info *mtd)
        }
 
        if (add_mtd_blktrans_dev(&nftl->mbd)) {
-               if (nftl->ReplUnitTable)
-                       kfree(nftl->ReplUnitTable);
-               if (nftl->EUNtable)
-                       kfree(nftl->EUNtable);
+               kfree(nftl->ReplUnitTable);
+               kfree(nftl->EUNtable);
                kfree(nftl);
                return;
        }
@@ -133,10 +131,8 @@ static void nftl_remove_dev(struct mtd_blktrans_dev *dev)
        DEBUG(MTD_DEBUG_LEVEL1, "NFTL: remove_dev (i=%d)\n", dev->devnum);
 
        del_mtd_blktrans_dev(dev);
-       if (nftl->ReplUnitTable)
-               kfree(nftl->ReplUnitTable);
-       if (nftl->EUNtable)
-               kfree(nftl->EUNtable);
+       kfree(nftl->ReplUnitTable);
+       kfree(nftl->EUNtable);
        kfree(nftl);
 }