diff options
author | Jesper Juhl <jesper.juhl@gmail.com> | 2005-11-07 04:01:27 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2005-11-07 10:54:02 -0500 |
commit | fa671646f61182cd18234461a6e65f50c6558695 (patch) | |
tree | 79d5fe8cbfdf9670456538837e60c695e6875006 | |
parent | c9475cb0c358ff0dd473544280d92482df491913 (diff) |
[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: 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>
-rw-r--r-- | drivers/mtd/chips/cfi_cmdset_0001.c | 3 | ||||
-rw-r--r-- | drivers/mtd/chips/cfi_cmdset_0002.c | 4 | ||||
-rw-r--r-- | drivers/mtd/devices/blkmtd.c | 7 | ||||
-rw-r--r-- | drivers/mtd/inftlcore.c | 12 | ||||
-rw-r--r-- | drivers/mtd/maps/amd76xrom.c | 4 | ||||
-rw-r--r-- | drivers/mtd/maps/bast-flash.c | 3 | ||||
-rw-r--r-- | drivers/mtd/maps/ceiva.c | 3 | ||||
-rw-r--r-- | drivers/mtd/maps/ichxrom.c | 5 | ||||
-rw-r--r-- | drivers/mtd/maps/integrator-flash.c | 6 | ||||
-rw-r--r-- | drivers/mtd/maps/ipaq-flash.c | 3 | ||||
-rw-r--r-- | drivers/mtd/maps/iq80310.c | 3 | ||||
-rw-r--r-- | drivers/mtd/maps/ixp2000.c | 3 | ||||
-rw-r--r-- | drivers/mtd/maps/ixp4xx.c | 3 | ||||
-rw-r--r-- | drivers/mtd/maps/lubbock-flash.c | 3 | ||||
-rw-r--r-- | drivers/mtd/maps/omap-toto-flash.c | 3 | ||||
-rw-r--r-- | drivers/mtd/maps/sa1100-flash.c | 3 | ||||
-rw-r--r-- | drivers/mtd/maps/sun_uflash.c | 4 | ||||
-rw-r--r-- | drivers/mtd/maps/tqm8xxl.c | 6 | ||||
-rw-r--r-- | drivers/mtd/nand/nand_base.c | 5 | ||||
-rw-r--r-- | drivers/mtd/nftlcore.c | 12 |
20 files changed, 32 insertions, 63 deletions
diff --git a/drivers/mtd/chips/cfi_cmdset_0001.c b/drivers/mtd/chips/cfi_cmdset_0001.c index 0cfcd88468e0..c3fc9b2f21fb 100644 --- a/drivers/mtd/chips/cfi_cmdset_0001.c +++ b/drivers/mtd/chips/cfi_cmdset_0001.c | |||
@@ -455,8 +455,7 @@ static struct mtd_info *cfi_intelext_setup(struct mtd_info *mtd) | |||
455 | 455 | ||
456 | setup_err: | 456 | setup_err: |
457 | if(mtd) { | 457 | if(mtd) { |
458 | if(mtd->eraseregions) | 458 | kfree(mtd->eraseregions); |
459 | kfree(mtd->eraseregions); | ||
460 | kfree(mtd); | 459 | kfree(mtd); |
461 | } | 460 | } |
462 | kfree(cfi->cmdset_priv); | 461 | kfree(cfi->cmdset_priv); |
diff --git a/drivers/mtd/chips/cfi_cmdset_0002.c b/drivers/mtd/chips/cfi_cmdset_0002.c index 8505f118f2db..0e6475050da9 100644 --- a/drivers/mtd/chips/cfi_cmdset_0002.c +++ b/drivers/mtd/chips/cfi_cmdset_0002.c | |||
@@ -378,8 +378,7 @@ static struct mtd_info *cfi_amdstd_setup(struct mtd_info *mtd) | |||
378 | 378 | ||
379 | setup_err: | 379 | setup_err: |
380 | if(mtd) { | 380 | if(mtd) { |
381 | if(mtd->eraseregions) | 381 | kfree(mtd->eraseregions); |
382 | kfree(mtd->eraseregions); | ||
383 | kfree(mtd); | 382 | kfree(mtd); |
384 | } | 383 | } |
385 | kfree(cfi->cmdset_priv); | 384 | kfree(cfi->cmdset_priv); |
@@ -1742,6 +1741,7 @@ static void cfi_amdstd_destroy(struct mtd_info *mtd) | |||
1742 | { | 1741 | { |
1743 | struct map_info *map = mtd->priv; | 1742 | struct map_info *map = mtd->priv; |
1744 | struct cfi_private *cfi = map->fldrv_priv; | 1743 | struct cfi_private *cfi = map->fldrv_priv; |
1744 | |||
1745 | kfree(cfi->cmdset_priv); | 1745 | kfree(cfi->cmdset_priv); |
1746 | kfree(cfi->cfiq); | 1746 | kfree(cfi->cfiq); |
1747 | kfree(cfi); | 1747 | kfree(cfi); |
diff --git a/drivers/mtd/devices/blkmtd.c b/drivers/mtd/devices/blkmtd.c index 662e807801ed..59a29e616a22 100644 --- a/drivers/mtd/devices/blkmtd.c +++ b/drivers/mtd/devices/blkmtd.c | |||
@@ -539,11 +539,8 @@ static void free_device(struct blkmtd_dev *dev) | |||
539 | { | 539 | { |
540 | DEBUG(2, "blkmtd: free_device() dev = %p\n", dev); | 540 | DEBUG(2, "blkmtd: free_device() dev = %p\n", dev); |
541 | if(dev) { | 541 | if(dev) { |
542 | if(dev->mtd_info.eraseregions) | 542 | kfree(dev->mtd_info.eraseregions); |
543 | kfree(dev->mtd_info.eraseregions); | 543 | kfree(dev->mtd_info.name); |
544 | if(dev->mtd_info.name) | ||
545 | kfree(dev->mtd_info.name); | ||
546 | |||
547 | if(dev->blkdev) { | 544 | if(dev->blkdev) { |
548 | invalidate_inode_pages(dev->blkdev->bd_inode->i_mapping); | 545 | invalidate_inode_pages(dev->blkdev->bd_inode->i_mapping); |
549 | close_bdev_excl(dev->blkdev); | 546 | close_bdev_excl(dev->blkdev); |
diff --git a/drivers/mtd/inftlcore.c b/drivers/mtd/inftlcore.c index 39eb53f6551f..8db65bf029ea 100644 --- a/drivers/mtd/inftlcore.c +++ b/drivers/mtd/inftlcore.c | |||
@@ -126,10 +126,8 @@ static void inftl_add_mtd(struct mtd_blktrans_ops *tr, struct mtd_info *mtd) | |||
126 | } | 126 | } |
127 | 127 | ||
128 | if (add_mtd_blktrans_dev(&inftl->mbd)) { | 128 | if (add_mtd_blktrans_dev(&inftl->mbd)) { |
129 | if (inftl->PUtable) | 129 | kfree(inftl->PUtable); |
130 | kfree(inftl->PUtable); | 130 | kfree(inftl->VUtable); |
131 | if (inftl->VUtable) | ||
132 | kfree(inftl->VUtable); | ||
133 | kfree(inftl); | 131 | kfree(inftl); |
134 | return; | 132 | return; |
135 | } | 133 | } |
@@ -147,10 +145,8 @@ static void inftl_remove_dev(struct mtd_blktrans_dev *dev) | |||
147 | 145 | ||
148 | del_mtd_blktrans_dev(dev); | 146 | del_mtd_blktrans_dev(dev); |
149 | 147 | ||
150 | if (inftl->PUtable) | 148 | kfree(inftl->PUtable); |
151 | kfree(inftl->PUtable); | 149 | kfree(inftl->VUtable); |
152 | if (inftl->VUtable) | ||
153 | kfree(inftl->VUtable); | ||
154 | kfree(inftl); | 150 | kfree(inftl); |
155 | } | 151 | } |
156 | 152 | ||
diff --git a/drivers/mtd/maps/amd76xrom.c b/drivers/mtd/maps/amd76xrom.c index e8a900a77685..9a64149f431d 100644 --- a/drivers/mtd/maps/amd76xrom.c +++ b/drivers/mtd/maps/amd76xrom.c | |||
@@ -259,9 +259,7 @@ static int __devinit amd76xrom_init_one (struct pci_dev *pdev, | |||
259 | 259 | ||
260 | out: | 260 | out: |
261 | /* Free any left over map structures */ | 261 | /* Free any left over map structures */ |
262 | if (map) { | 262 | kfree(map); |
263 | kfree(map); | ||
264 | } | ||
265 | /* See if I have any map structures */ | 263 | /* See if I have any map structures */ |
266 | if (list_empty(&window->maps)) { | 264 | if (list_empty(&window->maps)) { |
267 | amd76xrom_cleanup(window); | 265 | amd76xrom_cleanup(window); |
diff --git a/drivers/mtd/maps/bast-flash.c b/drivers/mtd/maps/bast-flash.c index bfe994e59265..8c19d722ac79 100644 --- a/drivers/mtd/maps/bast-flash.c +++ b/drivers/mtd/maps/bast-flash.c | |||
@@ -104,8 +104,7 @@ static int bast_flash_remove(struct device *dev) | |||
104 | map_destroy(info->mtd); | 104 | map_destroy(info->mtd); |
105 | } | 105 | } |
106 | 106 | ||
107 | if (info->partitions) | 107 | kfree(info->partitions); |
108 | kfree(info->partitions); | ||
109 | 108 | ||
110 | if (info->area) { | 109 | if (info->area) { |
111 | release_resource(info->area); | 110 | release_resource(info->area); |
diff --git a/drivers/mtd/maps/ceiva.c b/drivers/mtd/maps/ceiva.c index c68b31dc7e6d..5a95ab370a97 100644 --- a/drivers/mtd/maps/ceiva.c +++ b/drivers/mtd/maps/ceiva.c | |||
@@ -313,8 +313,7 @@ static void __init clps_locate_partitions(struct mtd_info *mtd) | |||
313 | 313 | ||
314 | static void __exit clps_destroy_partitions(void) | 314 | static void __exit clps_destroy_partitions(void) |
315 | { | 315 | { |
316 | if (parsed_parts) | 316 | kfree(parsed_parts); |
317 | kfree(parsed_parts); | ||
318 | } | 317 | } |
319 | 318 | ||
320 | static struct mtd_info *mymtd; | 319 | static struct mtd_info *mymtd; |
diff --git a/drivers/mtd/maps/ichxrom.c b/drivers/mtd/maps/ichxrom.c index e505207cd489..c5e2111ba146 100644 --- a/drivers/mtd/maps/ichxrom.c +++ b/drivers/mtd/maps/ichxrom.c | |||
@@ -306,9 +306,8 @@ static int __devinit ichxrom_init_one (struct pci_dev *pdev, | |||
306 | 306 | ||
307 | out: | 307 | out: |
308 | /* Free any left over map structures */ | 308 | /* Free any left over map structures */ |
309 | if (map) { | 309 | kfree(map); |
310 | kfree(map); | 310 | |
311 | } | ||
312 | /* See if I have any map structures */ | 311 | /* See if I have any map structures */ |
313 | if (list_empty(&window->maps)) { | 312 | if (list_empty(&window->maps)) { |
314 | ichxrom_cleanup(window); | 313 | ichxrom_cleanup(window); |
diff --git a/drivers/mtd/maps/integrator-flash.c b/drivers/mtd/maps/integrator-flash.c index d14a0185b8f4..93f50d6d5488 100644 --- a/drivers/mtd/maps/integrator-flash.c +++ b/drivers/mtd/maps/integrator-flash.c | |||
@@ -148,8 +148,7 @@ static int armflash_probe(struct device *_dev) | |||
148 | del_mtd_partitions(info->mtd); | 148 | del_mtd_partitions(info->mtd); |
149 | map_destroy(info->mtd); | 149 | map_destroy(info->mtd); |
150 | } | 150 | } |
151 | if (info->parts) | 151 | kfree(info->parts); |
152 | kfree(info->parts); | ||
153 | 152 | ||
154 | no_device: | 153 | no_device: |
155 | iounmap(base); | 154 | iounmap(base); |
@@ -176,8 +175,7 @@ static int armflash_remove(struct device *_dev) | |||
176 | del_mtd_partitions(info->mtd); | 175 | del_mtd_partitions(info->mtd); |
177 | map_destroy(info->mtd); | 176 | map_destroy(info->mtd); |
178 | } | 177 | } |
179 | if (info->parts) | 178 | kfree(info->parts); |
180 | kfree(info->parts); | ||
181 | 179 | ||
182 | iounmap(info->map.virt); | 180 | iounmap(info->map.virt); |
183 | release_resource(info->res); | 181 | release_resource(info->res); |
diff --git a/drivers/mtd/maps/ipaq-flash.c b/drivers/mtd/maps/ipaq-flash.c index 712401810841..70b0e0b82c34 100644 --- a/drivers/mtd/maps/ipaq-flash.c +++ b/drivers/mtd/maps/ipaq-flash.c | |||
@@ -431,8 +431,7 @@ static void __exit ipaq_mtd_cleanup(void) | |||
431 | if (my_sub_mtd[i]) | 431 | if (my_sub_mtd[i]) |
432 | map_destroy(my_sub_mtd[i]); | 432 | map_destroy(my_sub_mtd[i]); |
433 | } | 433 | } |
434 | if (parsed_parts) | 434 | kfree(parsed_parts); |
435 | kfree(parsed_parts); | ||
436 | } | 435 | } |
437 | } | 436 | } |
438 | 437 | ||
diff --git a/drivers/mtd/maps/iq80310.c b/drivers/mtd/maps/iq80310.c index 558d014e7acc..2e7577492a2c 100644 --- a/drivers/mtd/maps/iq80310.c +++ b/drivers/mtd/maps/iq80310.c | |||
@@ -103,8 +103,7 @@ static void __exit cleanup_iq80310(void) | |||
103 | if (mymtd) { | 103 | if (mymtd) { |
104 | del_mtd_partitions(mymtd); | 104 | del_mtd_partitions(mymtd); |
105 | map_destroy(mymtd); | 105 | map_destroy(mymtd); |
106 | if (parsed_parts) | 106 | kfree(parsed_parts); |
107 | kfree(parsed_parts); | ||
108 | } | 107 | } |
109 | if (iq80310_map.virt) | 108 | if (iq80310_map.virt) |
110 | iounmap((void *)iq80310_map.virt); | 109 | iounmap((void *)iq80310_map.virt); |
diff --git a/drivers/mtd/maps/ixp2000.c b/drivers/mtd/maps/ixp2000.c index 00b9f67580f1..6f36497022d1 100644 --- a/drivers/mtd/maps/ixp2000.c +++ b/drivers/mtd/maps/ixp2000.c | |||
@@ -129,8 +129,7 @@ static int ixp2000_flash_remove(struct device *_dev) | |||
129 | if (info->map.map_priv_1) | 129 | if (info->map.map_priv_1) |
130 | iounmap((void *) info->map.map_priv_1); | 130 | iounmap((void *) info->map.map_priv_1); |
131 | 131 | ||
132 | if (info->partitions) { | 132 | kfree(info->partitions); |
133 | kfree(info->partitions); } | ||
134 | 133 | ||
135 | if (info->res) { | 134 | if (info->res) { |
136 | release_resource(info->res); | 135 | release_resource(info->res); |
diff --git a/drivers/mtd/maps/ixp4xx.c b/drivers/mtd/maps/ixp4xx.c index 733a9297a562..0d87c02dee04 100644 --- a/drivers/mtd/maps/ixp4xx.c +++ b/drivers/mtd/maps/ixp4xx.c | |||
@@ -124,8 +124,7 @@ static int ixp4xx_flash_remove(struct device *_dev) | |||
124 | if (info->map.map_priv_1) | 124 | if (info->map.map_priv_1) |
125 | iounmap((void *) info->map.map_priv_1); | 125 | iounmap((void *) info->map.map_priv_1); |
126 | 126 | ||
127 | if (info->partitions) | 127 | kfree(info->partitions); |
128 | kfree(info->partitions); | ||
129 | 128 | ||
130 | if (info->res) { | 129 | if (info->res) { |
131 | release_resource(info->res); | 130 | release_resource(info->res); |
diff --git a/drivers/mtd/maps/lubbock-flash.c b/drivers/mtd/maps/lubbock-flash.c index 2337e0c46750..2b4c5058787d 100644 --- a/drivers/mtd/maps/lubbock-flash.c +++ b/drivers/mtd/maps/lubbock-flash.c | |||
@@ -158,8 +158,7 @@ static void __exit cleanup_lubbock(void) | |||
158 | if (lubbock_maps[i].cached) | 158 | if (lubbock_maps[i].cached) |
159 | iounmap(lubbock_maps[i].cached); | 159 | iounmap(lubbock_maps[i].cached); |
160 | 160 | ||
161 | if (parsed_parts[i]) | 161 | kfree(parsed_parts[i]); |
162 | kfree(parsed_parts[i]); | ||
163 | } | 162 | } |
164 | } | 163 | } |
165 | 164 | ||
diff --git a/drivers/mtd/maps/omap-toto-flash.c b/drivers/mtd/maps/omap-toto-flash.c index da36e8dddd17..763304154a92 100644 --- a/drivers/mtd/maps/omap-toto-flash.c +++ b/drivers/mtd/maps/omap-toto-flash.c | |||
@@ -124,8 +124,7 @@ static void __exit omap_toto_mtd_cleanup(void) | |||
124 | if (flash_mtd) { | 124 | if (flash_mtd) { |
125 | del_mtd_partitions(flash_mtd); | 125 | del_mtd_partitions(flash_mtd); |
126 | map_destroy(flash_mtd); | 126 | map_destroy(flash_mtd); |
127 | if (parsed_parts) | 127 | kfree(parsed_parts); |
128 | kfree(parsed_parts); | ||
129 | } | 128 | } |
130 | } | 129 | } |
131 | 130 | ||
diff --git a/drivers/mtd/maps/sa1100-flash.c b/drivers/mtd/maps/sa1100-flash.c index c8d0da19d897..a31f6ee8a4be 100644 --- a/drivers/mtd/maps/sa1100-flash.c +++ b/drivers/mtd/maps/sa1100-flash.c | |||
@@ -241,8 +241,7 @@ static void sa1100_destroy(struct sa_info *info, struct flash_platform_data *pla | |||
241 | #endif | 241 | #endif |
242 | } | 242 | } |
243 | 243 | ||
244 | if (info->parts) | 244 | kfree(info->parts); |
245 | kfree(info->parts); | ||
246 | 245 | ||
247 | for (i = info->num_subdev - 1; i >= 0; i--) | 246 | for (i = info->num_subdev - 1; i >= 0; i--) |
248 | sa1100_destroy_subdev(&info->subdev[i]); | 247 | sa1100_destroy_subdev(&info->subdev[i]); |
diff --git a/drivers/mtd/maps/sun_uflash.c b/drivers/mtd/maps/sun_uflash.c index 29091d10030a..1355c28f90a4 100644 --- a/drivers/mtd/maps/sun_uflash.c +++ b/drivers/mtd/maps/sun_uflash.c | |||
@@ -166,9 +166,7 @@ static void __exit uflash_cleanup(void) | |||
166 | iounmap(udev->map.virt); | 166 | iounmap(udev->map.virt); |
167 | udev->map.virt = NULL; | 167 | udev->map.virt = NULL; |
168 | } | 168 | } |
169 | if(0 != udev->name) { | 169 | kfree(udev->name); |
170 | kfree(udev->name); | ||
171 | } | ||
172 | kfree(udev); | 170 | kfree(udev); |
173 | } | 171 | } |
174 | } | 172 | } |
diff --git a/drivers/mtd/maps/tqm8xxl.c b/drivers/mtd/maps/tqm8xxl.c index 4e28b977f224..0aca8179f27f 100644 --- a/drivers/mtd/maps/tqm8xxl.c +++ b/drivers/mtd/maps/tqm8xxl.c | |||
@@ -224,10 +224,8 @@ int __init init_tqm_mtd(void) | |||
224 | error_mem: | 224 | error_mem: |
225 | for(idx = 0 ; idx < FLASH_BANK_MAX ; idx++) { | 225 | for(idx = 0 ; idx < FLASH_BANK_MAX ; idx++) { |
226 | if(map_banks[idx] != NULL) { | 226 | if(map_banks[idx] != NULL) { |
227 | if(map_banks[idx]->name != NULL) { | 227 | kfree(map_banks[idx]->name); |
228 | kfree(map_banks[idx]->name); | 228 | map_banks[idx]->name = NULL; |
229 | map_banks[idx]->name = NULL; | ||
230 | } | ||
231 | kfree(map_banks[idx]); | 229 | kfree(map_banks[idx]); |
232 | map_banks[idx] = NULL; | 230 | map_banks[idx] = NULL; |
233 | } | 231 | } |
diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c index 04e54318bc6a..8e78d7b96a56 100644 --- a/drivers/mtd/nand/nand_base.c +++ b/drivers/mtd/nand/nand_base.c | |||
@@ -2676,9 +2676,8 @@ void nand_release (struct mtd_info *mtd) | |||
2676 | /* Deregister the device */ | 2676 | /* Deregister the device */ |
2677 | del_mtd_device (mtd); | 2677 | del_mtd_device (mtd); |
2678 | 2678 | ||
2679 | /* Free bad block table memory, if allocated */ | 2679 | /* Free bad block table memory */ |
2680 | if (this->bbt) | 2680 | kfree (this->bbt); |
2681 | kfree (this->bbt); | ||
2682 | /* Buffer allocated by nand_scan ? */ | 2681 | /* Buffer allocated by nand_scan ? */ |
2683 | if (this->options & NAND_OOBBUF_ALLOC) | 2682 | if (this->options & NAND_OOBBUF_ALLOC) |
2684 | kfree (this->oob_buf); | 2683 | kfree (this->oob_buf); |
diff --git a/drivers/mtd/nftlcore.c b/drivers/mtd/nftlcore.c index b2014043634f..062ff3877536 100644 --- a/drivers/mtd/nftlcore.c +++ b/drivers/mtd/nftlcore.c | |||
@@ -114,10 +114,8 @@ static void nftl_add_mtd(struct mtd_blktrans_ops *tr, struct mtd_info *mtd) | |||
114 | } | 114 | } |
115 | 115 | ||
116 | if (add_mtd_blktrans_dev(&nftl->mbd)) { | 116 | if (add_mtd_blktrans_dev(&nftl->mbd)) { |
117 | if (nftl->ReplUnitTable) | 117 | kfree(nftl->ReplUnitTable); |
118 | kfree(nftl->ReplUnitTable); | 118 | kfree(nftl->EUNtable); |
119 | if (nftl->EUNtable) | ||
120 | kfree(nftl->EUNtable); | ||
121 | kfree(nftl); | 119 | kfree(nftl); |
122 | return; | 120 | return; |
123 | } | 121 | } |
@@ -133,10 +131,8 @@ static void nftl_remove_dev(struct mtd_blktrans_dev *dev) | |||
133 | DEBUG(MTD_DEBUG_LEVEL1, "NFTL: remove_dev (i=%d)\n", dev->devnum); | 131 | DEBUG(MTD_DEBUG_LEVEL1, "NFTL: remove_dev (i=%d)\n", dev->devnum); |
134 | 132 | ||
135 | del_mtd_blktrans_dev(dev); | 133 | del_mtd_blktrans_dev(dev); |
136 | if (nftl->ReplUnitTable) | 134 | kfree(nftl->ReplUnitTable); |
137 | kfree(nftl->ReplUnitTable); | 135 | kfree(nftl->EUNtable); |
138 | if (nftl->EUNtable) | ||
139 | kfree(nftl->EUNtable); | ||
140 | kfree(nftl); | 136 | kfree(nftl); |
141 | } | 137 | } |
142 | 138 | ||