diff options
| author | Burman Yan <yan_952@hotmail.com> | 2006-11-15 14:10:29 -0500 |
|---|---|---|
| committer | David Woodhouse <dwmw2@infradead.org> | 2006-11-28 18:47:21 -0500 |
| commit | 95b93a0cd46682c6d9e8eea803fda510cb6b863a (patch) | |
| tree | 7e430d3fc04ed20791187d144730dd3052292c67 | |
| parent | 998a43e72d20afa7566dad66fd866fe939a89c09 (diff) | |
[MTD] replace kmalloc+memset with kzalloc
Signed-off-by: Yan Burman <yan_952@hotmail.com>
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
41 files changed, 53 insertions, 125 deletions
diff --git a/arch/ppc/platforms/ev64360.c b/arch/ppc/platforms/ev64360.c index 90ed375c9b90..f87e06f6bab9 100644 --- a/arch/ppc/platforms/ev64360.c +++ b/arch/ppc/platforms/ev64360.c | |||
| @@ -358,13 +358,12 @@ ev64360_setup_mtd(void) | |||
| 358 | 358 | ||
| 359 | ptbl_entries = 3; | 359 | ptbl_entries = 3; |
| 360 | 360 | ||
| 361 | if ((ptbl = kmalloc(ptbl_entries * sizeof(struct mtd_partition), | 361 | if ((ptbl = kzalloc(ptbl_entries * sizeof(struct mtd_partition), |
| 362 | GFP_KERNEL)) == NULL) { | 362 | GFP_KERNEL)) == NULL) { |
| 363 | 363 | ||
| 364 | printk(KERN_WARNING "Can't alloc MTD partition table\n"); | 364 | printk(KERN_WARNING "Can't alloc MTD partition table\n"); |
| 365 | return -ENOMEM; | 365 | return -ENOMEM; |
| 366 | } | 366 | } |
| 367 | memset(ptbl, 0, ptbl_entries * sizeof(struct mtd_partition)); | ||
| 368 | 367 | ||
| 369 | ptbl[0].name = "reserved"; | 368 | ptbl[0].name = "reserved"; |
| 370 | ptbl[0].offset = 0; | 369 | ptbl[0].offset = 0; |
diff --git a/drivers/mtd/afs.c b/drivers/mtd/afs.c index 6a45be04564b..52d51eb91c16 100644 --- a/drivers/mtd/afs.c +++ b/drivers/mtd/afs.c | |||
| @@ -207,11 +207,10 @@ static int parse_afs_partitions(struct mtd_info *mtd, | |||
| 207 | if (!sz) | 207 | if (!sz) |
| 208 | return ret; | 208 | return ret; |
| 209 | 209 | ||
| 210 | parts = kmalloc(sz, GFP_KERNEL); | 210 | parts = kzalloc(sz, GFP_KERNEL); |
| 211 | if (!parts) | 211 | if (!parts) |
| 212 | return -ENOMEM; | 212 | return -ENOMEM; |
| 213 | 213 | ||
| 214 | memset(parts, 0, sz); | ||
| 215 | str = (char *)(parts + idx); | 214 | str = (char *)(parts + idx); |
| 216 | 215 | ||
| 217 | /* | 216 | /* |
diff --git a/drivers/mtd/chips/amd_flash.c b/drivers/mtd/chips/amd_flash.c index 16eaca69fb5a..e7999f15d85a 100644 --- a/drivers/mtd/chips/amd_flash.c +++ b/drivers/mtd/chips/amd_flash.c | |||
| @@ -643,13 +643,12 @@ static struct mtd_info *amd_flash_probe(struct map_info *map) | |||
| 643 | int reg_idx; | 643 | int reg_idx; |
| 644 | int offset; | 644 | int offset; |
| 645 | 645 | ||
| 646 | mtd = (struct mtd_info*)kmalloc(sizeof(*mtd), GFP_KERNEL); | 646 | mtd = kzalloc(sizeof(*mtd), GFP_KERNEL); |
| 647 | if (!mtd) { | 647 | if (!mtd) { |
| 648 | printk(KERN_WARNING | 648 | printk(KERN_WARNING |
| 649 | "%s: kmalloc failed for info structure\n", map->name); | 649 | "%s: kmalloc failed for info structure\n", map->name); |
| 650 | return NULL; | 650 | return NULL; |
| 651 | } | 651 | } |
| 652 | memset(mtd, 0, sizeof(*mtd)); | ||
| 653 | mtd->priv = map; | 652 | mtd->priv = map; |
| 654 | 653 | ||
| 655 | memset(&temp, 0, sizeof(temp)); | 654 | memset(&temp, 0, sizeof(temp)); |
diff --git a/drivers/mtd/chips/cfi_cmdset_0001.c b/drivers/mtd/chips/cfi_cmdset_0001.c index e24973636e61..11de54535526 100644 --- a/drivers/mtd/chips/cfi_cmdset_0001.c +++ b/drivers/mtd/chips/cfi_cmdset_0001.c | |||
| @@ -337,12 +337,11 @@ struct mtd_info *cfi_cmdset_0001(struct map_info *map, int primary) | |||
| 337 | struct mtd_info *mtd; | 337 | struct mtd_info *mtd; |
| 338 | int i; | 338 | int i; |
| 339 | 339 | ||
| 340 | mtd = kmalloc(sizeof(*mtd), GFP_KERNEL); | 340 | mtd = kzalloc(sizeof(*mtd), GFP_KERNEL); |
| 341 | if (!mtd) { | 341 | if (!mtd) { |
| 342 | printk(KERN_ERR "Failed to allocate memory for MTD device\n"); | 342 | printk(KERN_ERR "Failed to allocate memory for MTD device\n"); |
| 343 | return NULL; | 343 | return NULL; |
| 344 | } | 344 | } |
| 345 | memset(mtd, 0, sizeof(*mtd)); | ||
| 346 | mtd->priv = map; | 345 | mtd->priv = map; |
| 347 | mtd->type = MTD_NORFLASH; | 346 | mtd->type = MTD_NORFLASH; |
| 348 | 347 | ||
diff --git a/drivers/mtd/chips/cfi_cmdset_0002.c b/drivers/mtd/chips/cfi_cmdset_0002.c index ca0882b5819f..e3acd398fb37 100644 --- a/drivers/mtd/chips/cfi_cmdset_0002.c +++ b/drivers/mtd/chips/cfi_cmdset_0002.c | |||
| @@ -257,12 +257,11 @@ struct mtd_info *cfi_cmdset_0002(struct map_info *map, int primary) | |||
| 257 | struct mtd_info *mtd; | 257 | struct mtd_info *mtd; |
| 258 | int i; | 258 | int i; |
| 259 | 259 | ||
| 260 | mtd = kmalloc(sizeof(*mtd), GFP_KERNEL); | 260 | mtd = kzalloc(sizeof(*mtd), GFP_KERNEL); |
| 261 | if (!mtd) { | 261 | if (!mtd) { |
| 262 | printk(KERN_WARNING "Failed to allocate memory for MTD device\n"); | 262 | printk(KERN_WARNING "Failed to allocate memory for MTD device\n"); |
| 263 | return NULL; | 263 | return NULL; |
| 264 | } | 264 | } |
| 265 | memset(mtd, 0, sizeof(*mtd)); | ||
| 266 | mtd->priv = map; | 265 | mtd->priv = map; |
| 267 | mtd->type = MTD_NORFLASH; | 266 | mtd->type = MTD_NORFLASH; |
| 268 | 267 | ||
diff --git a/drivers/mtd/chips/cfi_cmdset_0020.c b/drivers/mtd/chips/cfi_cmdset_0020.c index fae70a5db540..d56849f5f107 100644 --- a/drivers/mtd/chips/cfi_cmdset_0020.c +++ b/drivers/mtd/chips/cfi_cmdset_0020.c | |||
| @@ -172,7 +172,7 @@ static struct mtd_info *cfi_staa_setup(struct map_info *map) | |||
| 172 | int i,j; | 172 | int i,j; |
| 173 | unsigned long devsize = (1<<cfi->cfiq->DevSize) * cfi->interleave; | 173 | unsigned long devsize = (1<<cfi->cfiq->DevSize) * cfi->interleave; |
| 174 | 174 | ||
| 175 | mtd = kmalloc(sizeof(*mtd), GFP_KERNEL); | 175 | mtd = kzalloc(sizeof(*mtd), GFP_KERNEL); |
| 176 | //printk(KERN_DEBUG "number of CFI chips: %d\n", cfi->numchips); | 176 | //printk(KERN_DEBUG "number of CFI chips: %d\n", cfi->numchips); |
| 177 | 177 | ||
| 178 | if (!mtd) { | 178 | if (!mtd) { |
| @@ -181,7 +181,6 @@ static struct mtd_info *cfi_staa_setup(struct map_info *map) | |||
| 181 | return NULL; | 181 | return NULL; |
| 182 | } | 182 | } |
| 183 | 183 | ||
| 184 | memset(mtd, 0, sizeof(*mtd)); | ||
| 185 | mtd->priv = map; | 184 | mtd->priv = map; |
| 186 | mtd->type = MTD_NORFLASH; | 185 | mtd->type = MTD_NORFLASH; |
| 187 | mtd->size = devsize * cfi->numchips; | 186 | mtd->size = devsize * cfi->numchips; |
diff --git a/drivers/mtd/chips/gen_probe.c b/drivers/mtd/chips/gen_probe.c index cdb0f590b40c..77843d560ae4 100644 --- a/drivers/mtd/chips/gen_probe.c +++ b/drivers/mtd/chips/gen_probe.c | |||
| @@ -113,13 +113,12 @@ static struct cfi_private *genprobe_ident_chips(struct map_info *map, struct chi | |||
| 113 | } | 113 | } |
| 114 | 114 | ||
| 115 | mapsize = (max_chips + BITS_PER_LONG-1) / BITS_PER_LONG; | 115 | mapsize = (max_chips + BITS_PER_LONG-1) / BITS_PER_LONG; |
| 116 | chip_map = kmalloc(mapsize, GFP_KERNEL); | 116 | chip_map = kzalloc(mapsize, GFP_KERNEL); |
| 117 | if (!chip_map) { | 117 | if (!chip_map) { |
| 118 | printk(KERN_WARNING "%s: kmalloc failed for CFI chip map\n", map->name); | 118 | printk(KERN_WARNING "%s: kmalloc failed for CFI chip map\n", map->name); |
| 119 | kfree(cfi.cfiq); | 119 | kfree(cfi.cfiq); |
| 120 | return NULL; | 120 | return NULL; |
| 121 | } | 121 | } |
| 122 | memset (chip_map, 0, mapsize); | ||
| 123 | 122 | ||
| 124 | set_bit(0, chip_map); /* Mark first chip valid */ | 123 | set_bit(0, chip_map); /* Mark first chip valid */ |
| 125 | 124 | ||
diff --git a/drivers/mtd/chips/jedec.c b/drivers/mtd/chips/jedec.c index 2c3f019197c1..14e57b2bf842 100644 --- a/drivers/mtd/chips/jedec.c +++ b/drivers/mtd/chips/jedec.c | |||
| @@ -116,11 +116,10 @@ static struct mtd_info *jedec_probe(struct map_info *map) | |||
| 116 | char Part[200]; | 116 | char Part[200]; |
| 117 | memset(&priv,0,sizeof(priv)); | 117 | memset(&priv,0,sizeof(priv)); |
| 118 | 118 | ||
| 119 | MTD = kmalloc(sizeof(struct mtd_info) + sizeof(struct jedec_private), GFP_KERNEL); | 119 | MTD = kzalloc(sizeof(struct mtd_info) + sizeof(struct jedec_private), GFP_KERNEL); |
| 120 | if (!MTD) | 120 | if (!MTD) |
| 121 | return NULL; | 121 | return NULL; |
| 122 | 122 | ||
| 123 | memset(MTD, 0, sizeof(struct mtd_info) + sizeof(struct jedec_private)); | ||
| 124 | priv = (struct jedec_private *)&MTD[1]; | 123 | priv = (struct jedec_private *)&MTD[1]; |
| 125 | 124 | ||
| 126 | my_bank_size = map->size; | 125 | my_bank_size = map->size; |
diff --git a/drivers/mtd/chips/map_absent.c b/drivers/mtd/chips/map_absent.c index ac01a949b687..fc478c0f93f5 100644 --- a/drivers/mtd/chips/map_absent.c +++ b/drivers/mtd/chips/map_absent.c | |||
| @@ -47,13 +47,11 @@ static struct mtd_info *map_absent_probe(struct map_info *map) | |||
| 47 | { | 47 | { |
| 48 | struct mtd_info *mtd; | 48 | struct mtd_info *mtd; |
| 49 | 49 | ||
| 50 | mtd = kmalloc(sizeof(*mtd), GFP_KERNEL); | 50 | mtd = kzalloc(sizeof(*mtd), GFP_KERNEL); |
| 51 | if (!mtd) { | 51 | if (!mtd) { |
| 52 | return NULL; | 52 | return NULL; |
| 53 | } | 53 | } |
| 54 | 54 | ||
| 55 | memset(mtd, 0, sizeof(*mtd)); | ||
| 56 | |||
| 57 | map->fldrv = &map_absent_chipdrv; | 55 | map->fldrv = &map_absent_chipdrv; |
| 58 | mtd->priv = map; | 56 | mtd->priv = map; |
| 59 | mtd->name = map->name; | 57 | mtd->name = map->name; |
diff --git a/drivers/mtd/chips/map_ram.c b/drivers/mtd/chips/map_ram.c index 3a66680abfd0..5cb6d5263661 100644 --- a/drivers/mtd/chips/map_ram.c +++ b/drivers/mtd/chips/map_ram.c | |||
| @@ -55,12 +55,10 @@ static struct mtd_info *map_ram_probe(struct map_info *map) | |||
| 55 | #endif | 55 | #endif |
| 56 | /* OK. It seems to be RAM. */ | 56 | /* OK. It seems to be RAM. */ |
| 57 | 57 | ||
| 58 | mtd = kmalloc(sizeof(*mtd), GFP_KERNEL); | 58 | mtd = kzalloc(sizeof(*mtd), GFP_KERNEL); |
| 59 | if (!mtd) | 59 | if (!mtd) |
| 60 | return NULL; | 60 | return NULL; |
| 61 | 61 | ||
| 62 | memset(mtd, 0, sizeof(*mtd)); | ||
| 63 | |||
| 64 | map->fldrv = &mapram_chipdrv; | 62 | map->fldrv = &mapram_chipdrv; |
| 65 | mtd->priv = map; | 63 | mtd->priv = map; |
| 66 | mtd->name = map->name; | 64 | mtd->name = map->name; |
diff --git a/drivers/mtd/chips/map_rom.c b/drivers/mtd/chips/map_rom.c index 1b328b1378fd..cb27f855074c 100644 --- a/drivers/mtd/chips/map_rom.c +++ b/drivers/mtd/chips/map_rom.c | |||
| @@ -31,12 +31,10 @@ static struct mtd_info *map_rom_probe(struct map_info *map) | |||
| 31 | { | 31 | { |
| 32 | struct mtd_info *mtd; | 32 | struct mtd_info *mtd; |
| 33 | 33 | ||
| 34 | mtd = kmalloc(sizeof(*mtd), GFP_KERNEL); | 34 | mtd = kzalloc(sizeof(*mtd), GFP_KERNEL); |
| 35 | if (!mtd) | 35 | if (!mtd) |
| 36 | return NULL; | 36 | return NULL; |
| 37 | 37 | ||
| 38 | memset(mtd, 0, sizeof(*mtd)); | ||
| 39 | |||
| 40 | map->fldrv = &maprom_chipdrv; | 38 | map->fldrv = &maprom_chipdrv; |
| 41 | mtd->priv = map; | 39 | mtd->priv = map; |
| 42 | mtd->name = map->name; | 40 | mtd->name = map->name; |
diff --git a/drivers/mtd/chips/sharp.c b/drivers/mtd/chips/sharp.c index 967abbecdff9..c9cd3d21ccfa 100644 --- a/drivers/mtd/chips/sharp.c +++ b/drivers/mtd/chips/sharp.c | |||
| @@ -112,18 +112,16 @@ static struct mtd_info *sharp_probe(struct map_info *map) | |||
| 112 | struct sharp_info *sharp = NULL; | 112 | struct sharp_info *sharp = NULL; |
| 113 | int width; | 113 | int width; |
| 114 | 114 | ||
| 115 | mtd = kmalloc(sizeof(*mtd), GFP_KERNEL); | 115 | mtd = kzalloc(sizeof(*mtd), GFP_KERNEL); |
| 116 | if(!mtd) | 116 | if(!mtd) |
| 117 | return NULL; | 117 | return NULL; |
| 118 | 118 | ||
| 119 | sharp = kmalloc(sizeof(*sharp), GFP_KERNEL); | 119 | sharp = kzalloc(sizeof(*sharp), GFP_KERNEL); |
| 120 | if(!sharp) { | 120 | if(!sharp) { |
| 121 | kfree(mtd); | 121 | kfree(mtd); |
| 122 | return NULL; | 122 | return NULL; |
| 123 | } | 123 | } |
| 124 | 124 | ||
| 125 | memset(mtd, 0, sizeof(*mtd)); | ||
| 126 | |||
| 127 | width = sharp_probe_map(map,mtd); | 125 | width = sharp_probe_map(map,mtd); |
| 128 | if(!width){ | 126 | if(!width){ |
| 129 | kfree(mtd); | 127 | kfree(mtd); |
| @@ -143,7 +141,6 @@ static struct mtd_info *sharp_probe(struct map_info *map) | |||
| 143 | mtd->writesize = 1; | 141 | mtd->writesize = 1; |
| 144 | mtd->name = map->name; | 142 | mtd->name = map->name; |
| 145 | 143 | ||
| 146 | memset(sharp, 0, sizeof(*sharp)); | ||
| 147 | sharp->chipshift = 23; | 144 | sharp->chipshift = 23; |
| 148 | sharp->numchips = 1; | 145 | sharp->numchips = 1; |
| 149 | sharp->chips[0].start = 0; | 146 | sharp->chips[0].start = 0; |
diff --git a/drivers/mtd/cmdlinepart.c b/drivers/mtd/cmdlinepart.c index 3402ce448702..23fab14f1637 100644 --- a/drivers/mtd/cmdlinepart.c +++ b/drivers/mtd/cmdlinepart.c | |||
| @@ -163,13 +163,12 @@ static struct mtd_partition * newpart(char *s, | |||
| 163 | *num_parts = this_part + 1; | 163 | *num_parts = this_part + 1; |
| 164 | alloc_size = *num_parts * sizeof(struct mtd_partition) + | 164 | alloc_size = *num_parts * sizeof(struct mtd_partition) + |
| 165 | extra_mem_size; | 165 | extra_mem_size; |
| 166 | parts = kmalloc(alloc_size, GFP_KERNEL); | 166 | parts = kzalloc(alloc_size, GFP_KERNEL); |
| 167 | if (!parts) | 167 | if (!parts) |
| 168 | { | 168 | { |
| 169 | printk(KERN_ERR ERRP "out of memory\n"); | 169 | printk(KERN_ERR ERRP "out of memory\n"); |
| 170 | return NULL; | 170 | return NULL; |
| 171 | } | 171 | } |
| 172 | memset(parts, 0, alloc_size); | ||
| 173 | extra_mem = (unsigned char *)(parts + *num_parts); | 172 | extra_mem = (unsigned char *)(parts + *num_parts); |
| 174 | } | 173 | } |
| 175 | /* enter this partition (offset will be calculated later if it is zero at this point) */ | 174 | /* enter this partition (offset will be calculated later if it is zero at this point) */ |
diff --git a/drivers/mtd/devices/block2mtd.c b/drivers/mtd/devices/block2mtd.c index 401c6a294baa..6d917a4daa9d 100644 --- a/drivers/mtd/devices/block2mtd.c +++ b/drivers/mtd/devices/block2mtd.c | |||
| @@ -295,10 +295,9 @@ static struct block2mtd_dev *add_device(char *devname, int erase_size) | |||
| 295 | if (!devname) | 295 | if (!devname) |
| 296 | return NULL; | 296 | return NULL; |
| 297 | 297 | ||
| 298 | dev = kmalloc(sizeof(struct block2mtd_dev), GFP_KERNEL); | 298 | dev = kzalloc(sizeof(struct block2mtd_dev), GFP_KERNEL); |
| 299 | if (!dev) | 299 | if (!dev) |
| 300 | return NULL; | 300 | return NULL; |
| 301 | memset(dev, 0, sizeof(*dev)); | ||
| 302 | 301 | ||
| 303 | /* Get a handle on the device */ | 302 | /* Get a handle on the device */ |
| 304 | bdev = open_bdev_excl(devname, O_RDWR, NULL); | 303 | bdev = open_bdev_excl(devname, O_RDWR, NULL); |
diff --git a/drivers/mtd/devices/ms02-nv.c b/drivers/mtd/devices/ms02-nv.c index 08dfb899b272..9cff119a2024 100644 --- a/drivers/mtd/devices/ms02-nv.c +++ b/drivers/mtd/devices/ms02-nv.c | |||
| @@ -131,11 +131,10 @@ static int __init ms02nv_init_one(ulong addr) | |||
| 131 | int ret = -ENODEV; | 131 | int ret = -ENODEV; |
| 132 | 132 | ||
| 133 | /* The module decodes 8MiB of address space. */ | 133 | /* The module decodes 8MiB of address space. */ |
| 134 | mod_res = kmalloc(sizeof(*mod_res), GFP_KERNEL); | 134 | mod_res = kzalloc(sizeof(*mod_res), GFP_KERNEL); |
| 135 | if (!mod_res) | 135 | if (!mod_res) |
| 136 | return -ENOMEM; | 136 | return -ENOMEM; |
| 137 | 137 | ||
| 138 | memset(mod_res, 0, sizeof(*mod_res)); | ||
| 139 | mod_res->name = ms02nv_name; | 138 | mod_res->name = ms02nv_name; |
| 140 | mod_res->start = addr; | 139 | mod_res->start = addr; |
| 141 | mod_res->end = addr + MS02NV_SLOT_SIZE - 1; | 140 | mod_res->end = addr + MS02NV_SLOT_SIZE - 1; |
| @@ -153,24 +152,21 @@ static int __init ms02nv_init_one(ulong addr) | |||
| 153 | } | 152 | } |
| 154 | 153 | ||
| 155 | ret = -ENOMEM; | 154 | ret = -ENOMEM; |
| 156 | mtd = kmalloc(sizeof(*mtd), GFP_KERNEL); | 155 | mtd = kzalloc(sizeof(*mtd), GFP_KERNEL); |
| 157 | if (!mtd) | 156 | if (!mtd) |
| 158 | goto err_out_mod_res_rel; | 157 | goto err_out_mod_res_rel; |
| 159 | memset(mtd, 0, sizeof(*mtd)); | 158 | mp = kzalloc(sizeof(*mp), GFP_KERNEL); |
| 160 | mp = kmalloc(sizeof(*mp), GFP_KERNEL); | ||
| 161 | if (!mp) | 159 | if (!mp) |
| 162 | goto err_out_mtd; | 160 | goto err_out_mtd; |
| 163 | memset(mp, 0, sizeof(*mp)); | ||
| 164 | 161 | ||
| 165 | mtd->priv = mp; | 162 | mtd->priv = mp; |
| 166 | mp->resource.module = mod_res; | 163 | mp->resource.module = mod_res; |
| 167 | 164 | ||
| 168 | /* Firmware's diagnostic NVRAM area. */ | 165 | /* Firmware's diagnostic NVRAM area. */ |
| 169 | diag_res = kmalloc(sizeof(*diag_res), GFP_KERNEL); | 166 | diag_res = kzalloc(sizeof(*diag_res), GFP_KERNEL); |
| 170 | if (!diag_res) | 167 | if (!diag_res) |
| 171 | goto err_out_mp; | 168 | goto err_out_mp; |
| 172 | 169 | ||
| 173 | memset(diag_res, 0, sizeof(*diag_res)); | ||
| 174 | diag_res->name = ms02nv_res_diag_ram; | 170 | diag_res->name = ms02nv_res_diag_ram; |
| 175 | diag_res->start = addr; | 171 | diag_res->start = addr; |
| 176 | diag_res->end = addr + MS02NV_RAM - 1; | 172 | diag_res->end = addr + MS02NV_RAM - 1; |
| @@ -180,11 +176,10 @@ static int __init ms02nv_init_one(ulong addr) | |||
| 180 | mp->resource.diag_ram = diag_res; | 176 | mp->resource.diag_ram = diag_res; |
| 181 | 177 | ||
| 182 | /* User-available general-purpose NVRAM area. */ | 178 | /* User-available general-purpose NVRAM area. */ |
| 183 | user_res = kmalloc(sizeof(*user_res), GFP_KERNEL); | 179 | user_res = kzalloc(sizeof(*user_res), GFP_KERNEL); |
| 184 | if (!user_res) | 180 | if (!user_res) |
| 185 | goto err_out_diag_res; | 181 | goto err_out_diag_res; |
| 186 | 182 | ||
| 187 | memset(user_res, 0, sizeof(*user_res)); | ||
| 188 | user_res->name = ms02nv_res_user_ram; | 183 | user_res->name = ms02nv_res_user_ram; |
| 189 | user_res->start = addr + MS02NV_RAM; | 184 | user_res->start = addr + MS02NV_RAM; |
| 190 | user_res->end = addr + size - 1; | 185 | user_res->end = addr + size - 1; |
| @@ -194,11 +189,10 @@ static int __init ms02nv_init_one(ulong addr) | |||
| 194 | mp->resource.user_ram = user_res; | 189 | mp->resource.user_ram = user_res; |
| 195 | 190 | ||
| 196 | /* Control and status register. */ | 191 | /* Control and status register. */ |
| 197 | csr_res = kmalloc(sizeof(*csr_res), GFP_KERNEL); | 192 | csr_res = kzalloc(sizeof(*csr_res), GFP_KERNEL); |
| 198 | if (!csr_res) | 193 | if (!csr_res) |
| 199 | goto err_out_user_res; | 194 | goto err_out_user_res; |
| 200 | 195 | ||
| 201 | memset(csr_res, 0, sizeof(*csr_res)); | ||
| 202 | csr_res->name = ms02nv_res_csr; | 196 | csr_res->name = ms02nv_res_csr; |
| 203 | csr_res->start = addr + MS02NV_CSR; | 197 | csr_res->start = addr + MS02NV_CSR; |
| 204 | csr_res->end = addr + MS02NV_CSR + 3; | 198 | csr_res->end = addr + MS02NV_CSR + 3; |
diff --git a/drivers/mtd/devices/phram.c b/drivers/mtd/devices/phram.c index 6c7337f9ebbb..56cc1ca7ffd5 100644 --- a/drivers/mtd/devices/phram.c +++ b/drivers/mtd/devices/phram.c | |||
| @@ -126,12 +126,10 @@ static int register_device(char *name, unsigned long start, unsigned long len) | |||
| 126 | struct phram_mtd_list *new; | 126 | struct phram_mtd_list *new; |
| 127 | int ret = -ENOMEM; | 127 | int ret = -ENOMEM; |
| 128 | 128 | ||
| 129 | new = kmalloc(sizeof(*new), GFP_KERNEL); | 129 | new = kzalloc(sizeof(*new), GFP_KERNEL); |
| 130 | if (!new) | 130 | if (!new) |
| 131 | goto out0; | 131 | goto out0; |
| 132 | 132 | ||
| 133 | memset(new, 0, sizeof(*new)); | ||
| 134 | |||
| 135 | ret = -EIO; | 133 | ret = -EIO; |
| 136 | new->mtd.priv = ioremap(start, len); | 134 | new->mtd.priv = ioremap(start, len); |
| 137 | if (!new->mtd.priv) { | 135 | if (!new->mtd.priv) { |
diff --git a/drivers/mtd/devices/slram.c b/drivers/mtd/devices/slram.c index 542a0c009006..5f49248a4856 100644 --- a/drivers/mtd/devices/slram.c +++ b/drivers/mtd/devices/slram.c | |||
| @@ -168,19 +168,16 @@ static int register_device(char *name, unsigned long start, unsigned long length | |||
| 168 | E("slram: Cannot allocate new MTD device.\n"); | 168 | E("slram: Cannot allocate new MTD device.\n"); |
| 169 | return(-ENOMEM); | 169 | return(-ENOMEM); |
| 170 | } | 170 | } |
| 171 | (*curmtd)->mtdinfo = kmalloc(sizeof(struct mtd_info), GFP_KERNEL); | 171 | (*curmtd)->mtdinfo = kzalloc(sizeof(struct mtd_info), GFP_KERNEL); |
| 172 | (*curmtd)->next = NULL; | 172 | (*curmtd)->next = NULL; |
| 173 | 173 | ||
| 174 | if ((*curmtd)->mtdinfo) { | 174 | if ((*curmtd)->mtdinfo) { |
| 175 | memset((char *)(*curmtd)->mtdinfo, 0, sizeof(struct mtd_info)); | ||
| 176 | (*curmtd)->mtdinfo->priv = | 175 | (*curmtd)->mtdinfo->priv = |
| 177 | kmalloc(sizeof(slram_priv_t), GFP_KERNEL); | 176 | kzalloc(sizeof(slram_priv_t), GFP_KERNEL); |
| 178 | 177 | ||
| 179 | if (!(*curmtd)->mtdinfo->priv) { | 178 | if (!(*curmtd)->mtdinfo->priv) { |
| 180 | kfree((*curmtd)->mtdinfo); | 179 | kfree((*curmtd)->mtdinfo); |
| 181 | (*curmtd)->mtdinfo = NULL; | 180 | (*curmtd)->mtdinfo = NULL; |
| 182 | } else { | ||
| 183 | memset((*curmtd)->mtdinfo->priv,0,sizeof(slram_priv_t)); | ||
| 184 | } | 181 | } |
| 185 | } | 182 | } |
| 186 | 183 | ||
diff --git a/drivers/mtd/ftl.c b/drivers/mtd/ftl.c index da39355132d8..24235d4f1d23 100644 --- a/drivers/mtd/ftl.c +++ b/drivers/mtd/ftl.c | |||
| @@ -1033,7 +1033,7 @@ static void ftl_add_mtd(struct mtd_blktrans_ops *tr, struct mtd_info *mtd) | |||
| 1033 | { | 1033 | { |
| 1034 | partition_t *partition; | 1034 | partition_t *partition; |
| 1035 | 1035 | ||
| 1036 | partition = kmalloc(sizeof(partition_t), GFP_KERNEL); | 1036 | partition = kzalloc(sizeof(partition_t), GFP_KERNEL); |
| 1037 | 1037 | ||
| 1038 | if (!partition) { | 1038 | if (!partition) { |
| 1039 | printk(KERN_WARNING "No memory to scan for FTL on %s\n", | 1039 | printk(KERN_WARNING "No memory to scan for FTL on %s\n", |
| @@ -1041,8 +1041,6 @@ static void ftl_add_mtd(struct mtd_blktrans_ops *tr, struct mtd_info *mtd) | |||
| 1041 | return; | 1041 | return; |
| 1042 | } | 1042 | } |
| 1043 | 1043 | ||
| 1044 | memset(partition, 0, sizeof(partition_t)); | ||
| 1045 | |||
| 1046 | partition->mbd.mtd = mtd; | 1044 | partition->mbd.mtd = mtd; |
| 1047 | 1045 | ||
| 1048 | if ((scan_header(partition) == 0) && | 1046 | if ((scan_header(partition) == 0) && |
diff --git a/drivers/mtd/inftlcore.c b/drivers/mtd/inftlcore.c index d2f54c037e0f..b0e396504e67 100644 --- a/drivers/mtd/inftlcore.c +++ b/drivers/mtd/inftlcore.c | |||
| @@ -67,13 +67,12 @@ static void inftl_add_mtd(struct mtd_blktrans_ops *tr, struct mtd_info *mtd) | |||
| 67 | 67 | ||
| 68 | DEBUG(MTD_DEBUG_LEVEL3, "INFTL: add_mtd for %s\n", mtd->name); | 68 | DEBUG(MTD_DEBUG_LEVEL3, "INFTL: add_mtd for %s\n", mtd->name); |
| 69 | 69 | ||
| 70 | inftl = kmalloc(sizeof(*inftl), GFP_KERNEL); | 70 | inftl = kzalloc(sizeof(*inftl), GFP_KERNEL); |
| 71 | 71 | ||
| 72 | if (!inftl) { | 72 | if (!inftl) { |
| 73 | printk(KERN_WARNING "INFTL: Out of memory for data structures\n"); | 73 | printk(KERN_WARNING "INFTL: Out of memory for data structures\n"); |
| 74 | return; | 74 | return; |
| 75 | } | 75 | } |
| 76 | memset(inftl, 0, sizeof(*inftl)); | ||
| 77 | 76 | ||
| 78 | inftl->mbd.mtd = mtd; | 77 | inftl->mbd.mtd = mtd; |
| 79 | inftl->mbd.devnum = -1; | 78 | inftl->mbd.devnum = -1; |
diff --git a/drivers/mtd/maps/ceiva.c b/drivers/mtd/maps/ceiva.c index 0402c21e291d..629e6e2641a8 100644 --- a/drivers/mtd/maps/ceiva.c +++ b/drivers/mtd/maps/ceiva.c | |||
| @@ -122,10 +122,9 @@ static int __init clps_setup_mtd(struct clps_info *clps, int nr, struct mtd_info | |||
| 122 | /* | 122 | /* |
| 123 | * Allocate the map_info structs in one go. | 123 | * Allocate the map_info structs in one go. |
| 124 | */ | 124 | */ |
| 125 | maps = kmalloc(sizeof(struct map_info) * nr, GFP_KERNEL); | 125 | maps = kzalloc(sizeof(struct map_info) * nr, GFP_KERNEL); |
| 126 | if (!maps) | 126 | if (!maps) |
| 127 | return -ENOMEM; | 127 | return -ENOMEM; |
| 128 | memset(maps, 0, sizeof(struct map_info) * nr); | ||
| 129 | /* | 128 | /* |
| 130 | * Claim and then map the memory regions. | 129 | * Claim and then map the memory regions. |
| 131 | */ | 130 | */ |
diff --git a/drivers/mtd/maps/integrator-flash.c b/drivers/mtd/maps/integrator-flash.c index c8db01b3e45f..6946d802e6f6 100644 --- a/drivers/mtd/maps/integrator-flash.c +++ b/drivers/mtd/maps/integrator-flash.c | |||
| @@ -75,14 +75,12 @@ static int armflash_probe(struct platform_device *dev) | |||
| 75 | int err; | 75 | int err; |
| 76 | void __iomem *base; | 76 | void __iomem *base; |
| 77 | 77 | ||
| 78 | info = kmalloc(sizeof(struct armflash_info), GFP_KERNEL); | 78 | info = kzalloc(sizeof(struct armflash_info), GFP_KERNEL); |
| 79 | if (!info) { | 79 | if (!info) { |
| 80 | err = -ENOMEM; | 80 | err = -ENOMEM; |
| 81 | goto out; | 81 | goto out; |
| 82 | } | 82 | } |
| 83 | 83 | ||
| 84 | memset(info, 0, sizeof(struct armflash_info)); | ||
| 85 | |||
| 86 | info->plat = plat; | 84 | info->plat = plat; |
| 87 | if (plat && plat->init) { | 85 | if (plat && plat->init) { |
| 88 | err = plat->init(); | 86 | err = plat->init(); |
diff --git a/drivers/mtd/maps/omap_nor.c b/drivers/mtd/maps/omap_nor.c index 418afffb2d80..e8d9ae535673 100644 --- a/drivers/mtd/maps/omap_nor.c +++ b/drivers/mtd/maps/omap_nor.c | |||
| @@ -78,12 +78,10 @@ static int __devinit omapflash_probe(struct platform_device *pdev) | |||
| 78 | struct resource *res = pdev->resource; | 78 | struct resource *res = pdev->resource; |
| 79 | unsigned long size = res->end - res->start + 1; | 79 | unsigned long size = res->end - res->start + 1; |
| 80 | 80 | ||
| 81 | info = kmalloc(sizeof(struct omapflash_info), GFP_KERNEL); | 81 | info = kzalloc(sizeof(struct omapflash_info), GFP_KERNEL); |
| 82 | if (!info) | 82 | if (!info) |
| 83 | return -ENOMEM; | 83 | return -ENOMEM; |
| 84 | 84 | ||
| 85 | memset(info, 0, sizeof(struct omapflash_info)); | ||
| 86 | |||
| 87 | if (!request_mem_region(res->start, size, "flash")) { | 85 | if (!request_mem_region(res->start, size, "flash")) { |
| 88 | err = -EBUSY; | 86 | err = -EBUSY; |
| 89 | goto out_free_info; | 87 | goto out_free_info; |
diff --git a/drivers/mtd/maps/pcmciamtd.c b/drivers/mtd/maps/pcmciamtd.c index 995347b1beba..eaeb56a4070a 100644 --- a/drivers/mtd/maps/pcmciamtd.c +++ b/drivers/mtd/maps/pcmciamtd.c | |||
| @@ -735,11 +735,10 @@ static int pcmciamtd_probe(struct pcmcia_device *link) | |||
| 735 | struct pcmciamtd_dev *dev; | 735 | struct pcmciamtd_dev *dev; |
| 736 | 736 | ||
| 737 | /* Create new memory card device */ | 737 | /* Create new memory card device */ |
| 738 | dev = kmalloc(sizeof(*dev), GFP_KERNEL); | 738 | dev = kzalloc(sizeof(*dev), GFP_KERNEL); |
| 739 | if (!dev) return -ENOMEM; | 739 | if (!dev) return -ENOMEM; |
| 740 | DEBUG(1, "dev=0x%p", dev); | 740 | DEBUG(1, "dev=0x%p", dev); |
| 741 | 741 | ||
| 742 | memset(dev, 0, sizeof(*dev)); | ||
| 743 | dev->p_dev = link; | 742 | dev->p_dev = link; |
| 744 | link->priv = dev; | 743 | link->priv = dev; |
| 745 | 744 | ||
diff --git a/drivers/mtd/maps/physmap.c b/drivers/mtd/maps/physmap.c index bb67c505b1a5..28c5ffd75233 100644 --- a/drivers/mtd/maps/physmap.c +++ b/drivers/mtd/maps/physmap.c | |||
| @@ -92,12 +92,11 @@ static int physmap_flash_probe(struct platform_device *dev) | |||
| 92 | (unsigned long long)(dev->resource->end - dev->resource->start + 1), | 92 | (unsigned long long)(dev->resource->end - dev->resource->start + 1), |
| 93 | (unsigned long long)dev->resource->start); | 93 | (unsigned long long)dev->resource->start); |
| 94 | 94 | ||
| 95 | info = kmalloc(sizeof(struct physmap_flash_info), GFP_KERNEL); | 95 | info = kzalloc(sizeof(struct physmap_flash_info), GFP_KERNEL); |
| 96 | if (info == NULL) { | 96 | if (info == NULL) { |
| 97 | err = -ENOMEM; | 97 | err = -ENOMEM; |
| 98 | goto err_out; | 98 | goto err_out; |
| 99 | } | 99 | } |
| 100 | memset(info, 0, sizeof(*info)); | ||
| 101 | 100 | ||
| 102 | platform_set_drvdata(dev, info); | 101 | platform_set_drvdata(dev, info); |
| 103 | 102 | ||
diff --git a/drivers/mtd/maps/plat-ram.c b/drivers/mtd/maps/plat-ram.c index 5d3c75451ca2..2b6504ecbbd1 100644 --- a/drivers/mtd/maps/plat-ram.c +++ b/drivers/mtd/maps/plat-ram.c | |||
| @@ -147,14 +147,13 @@ static int platram_probe(struct platform_device *pdev) | |||
| 147 | 147 | ||
| 148 | pdata = pdev->dev.platform_data; | 148 | pdata = pdev->dev.platform_data; |
| 149 | 149 | ||
| 150 | info = kmalloc(sizeof(*info), GFP_KERNEL); | 150 | info = kzalloc(sizeof(*info), GFP_KERNEL); |
| 151 | if (info == NULL) { | 151 | if (info == NULL) { |
| 152 | dev_err(&pdev->dev, "no memory for flash info\n"); | 152 | dev_err(&pdev->dev, "no memory for flash info\n"); |
| 153 | err = -ENOMEM; | 153 | err = -ENOMEM; |
| 154 | goto exit_error; | 154 | goto exit_error; |
| 155 | } | 155 | } |
| 156 | 156 | ||
| 157 | memset(info, 0, sizeof(*info)); | ||
| 158 | platform_set_drvdata(pdev, info); | 157 | platform_set_drvdata(pdev, info); |
| 159 | 158 | ||
| 160 | info->dev = &pdev->dev; | 159 | info->dev = &pdev->dev; |
diff --git a/drivers/mtd/maps/sa1100-flash.c b/drivers/mtd/maps/sa1100-flash.c index 950bf1c57841..f904e6bd02e0 100644 --- a/drivers/mtd/maps/sa1100-flash.c +++ b/drivers/mtd/maps/sa1100-flash.c | |||
| @@ -273,14 +273,12 @@ sa1100_setup_mtd(struct platform_device *pdev, struct flash_platform_data *plat) | |||
| 273 | /* | 273 | /* |
| 274 | * Allocate the map_info structs in one go. | 274 | * Allocate the map_info structs in one go. |
| 275 | */ | 275 | */ |
| 276 | info = kmalloc(size, GFP_KERNEL); | 276 | info = kzalloc(size, GFP_KERNEL); |
| 277 | if (!info) { | 277 | if (!info) { |
| 278 | ret = -ENOMEM; | 278 | ret = -ENOMEM; |
| 279 | goto out; | 279 | goto out; |
| 280 | } | 280 | } |
| 281 | 281 | ||
| 282 | memset(info, 0, size); | ||
| 283 | |||
| 284 | if (plat->init) { | 282 | if (plat->init) { |
| 285 | ret = plat->init(); | 283 | ret = plat->init(); |
| 286 | if (ret) | 284 | if (ret) |
diff --git a/drivers/mtd/maps/tqm834x.c b/drivers/mtd/maps/tqm834x.c index 58e5912bd381..9adc970e55e6 100644 --- a/drivers/mtd/maps/tqm834x.c +++ b/drivers/mtd/maps/tqm834x.c | |||
| @@ -132,20 +132,16 @@ static int __init init_tqm834x_mtd(void) | |||
| 132 | 132 | ||
| 133 | pr_debug("%s: chip probing count %d\n", __FUNCTION__, idx); | 133 | pr_debug("%s: chip probing count %d\n", __FUNCTION__, idx); |
| 134 | 134 | ||
| 135 | map_banks[idx] = | 135 | map_banks[idx] = kzalloc(sizeof(struct map_info), GFP_KERNEL); |
| 136 | (struct map_info *)kmalloc(sizeof(struct map_info), | ||
| 137 | GFP_KERNEL); | ||
| 138 | if (map_banks[idx] == NULL) { | 136 | if (map_banks[idx] == NULL) { |
| 139 | ret = -ENOMEM; | 137 | ret = -ENOMEM; |
| 140 | goto error_mem; | 138 | goto error_mem; |
| 141 | } | 139 | } |
| 142 | memset((void *)map_banks[idx], 0, sizeof(struct map_info)); | 140 | map_banks[idx]->name = kzalloc(16, GFP_KERNEL); |
| 143 | map_banks[idx]->name = (char *)kmalloc(16, GFP_KERNEL); | ||
| 144 | if (map_banks[idx]->name == NULL) { | 141 | if (map_banks[idx]->name == NULL) { |
| 145 | ret = -ENOMEM; | 142 | ret = -ENOMEM; |
| 146 | goto error_mem; | 143 | goto error_mem; |
| 147 | } | 144 | } |
| 148 | memset((void *)map_banks[idx]->name, 0, 16); | ||
| 149 | 145 | ||
| 150 | sprintf(map_banks[idx]->name, "TQM834x-%d", idx); | 146 | sprintf(map_banks[idx]->name, "TQM834x-%d", idx); |
| 151 | map_banks[idx]->size = flash_size; | 147 | map_banks[idx]->size = flash_size; |
diff --git a/drivers/mtd/maps/tqm8xxl.c b/drivers/mtd/maps/tqm8xxl.c index 19578ba84ee8..37e4ded9b600 100644 --- a/drivers/mtd/maps/tqm8xxl.c +++ b/drivers/mtd/maps/tqm8xxl.c | |||
| @@ -134,14 +134,13 @@ int __init init_tqm_mtd(void) | |||
| 134 | 134 | ||
| 135 | printk(KERN_INFO "%s: chip probing count %d\n", __FUNCTION__, idx); | 135 | printk(KERN_INFO "%s: chip probing count %d\n", __FUNCTION__, idx); |
| 136 | 136 | ||
| 137 | map_banks[idx] = (struct map_info *)kmalloc(sizeof(struct map_info), GFP_KERNEL); | 137 | map_banks[idx] = kzalloc(sizeof(struct map_info), GFP_KERNEL); |
| 138 | if(map_banks[idx] == NULL) { | 138 | if(map_banks[idx] == NULL) { |
| 139 | ret = -ENOMEM; | 139 | ret = -ENOMEM; |
| 140 | /* FIXME: What if some MTD devices were probed already? */ | 140 | /* FIXME: What if some MTD devices were probed already? */ |
| 141 | goto error_mem; | 141 | goto error_mem; |
| 142 | } | 142 | } |
| 143 | 143 | ||
| 144 | memset((void *)map_banks[idx], 0, sizeof(struct map_info)); | ||
| 145 | map_banks[idx]->name = (char *)kmalloc(16, GFP_KERNEL); | 144 | map_banks[idx]->name = (char *)kmalloc(16, GFP_KERNEL); |
| 146 | 145 | ||
| 147 | if (!map_banks[idx]->name) { | 146 | if (!map_banks[idx]->name) { |
diff --git a/drivers/mtd/mtd_blkdevs.c b/drivers/mtd/mtd_blkdevs.c index b5d62cb357da..b879a66daa9e 100644 --- a/drivers/mtd/mtd_blkdevs.c +++ b/drivers/mtd/mtd_blkdevs.c | |||
| @@ -373,12 +373,10 @@ int register_mtd_blktrans(struct mtd_blktrans_ops *tr) | |||
| 373 | if (!blktrans_notifier.list.next) | 373 | if (!blktrans_notifier.list.next) |
| 374 | register_mtd_user(&blktrans_notifier); | 374 | register_mtd_user(&blktrans_notifier); |
| 375 | 375 | ||
| 376 | tr->blkcore_priv = kmalloc(sizeof(*tr->blkcore_priv), GFP_KERNEL); | 376 | tr->blkcore_priv = kzalloc(sizeof(*tr->blkcore_priv), GFP_KERNEL); |
| 377 | if (!tr->blkcore_priv) | 377 | if (!tr->blkcore_priv) |
| 378 | return -ENOMEM; | 378 | return -ENOMEM; |
| 379 | 379 | ||
| 380 | memset(tr->blkcore_priv, 0, sizeof(*tr->blkcore_priv)); | ||
| 381 | |||
| 382 | mutex_lock(&mtd_table_mutex); | 380 | mutex_lock(&mtd_table_mutex); |
| 383 | 381 | ||
| 384 | ret = register_blkdev(tr->major, tr->name); | 382 | ret = register_blkdev(tr->major, tr->name); |
diff --git a/drivers/mtd/mtdblock.c b/drivers/mtd/mtdblock.c index a052648f6e31..952da30b1745 100644 --- a/drivers/mtd/mtdblock.c +++ b/drivers/mtd/mtdblock.c | |||
| @@ -278,11 +278,10 @@ static int mtdblock_open(struct mtd_blktrans_dev *mbd) | |||
| 278 | } | 278 | } |
| 279 | 279 | ||
| 280 | /* OK, it's not open. Create cache info for it */ | 280 | /* OK, it's not open. Create cache info for it */ |
| 281 | mtdblk = kmalloc(sizeof(struct mtdblk_dev), GFP_KERNEL); | 281 | mtdblk = kzalloc(sizeof(struct mtdblk_dev), GFP_KERNEL); |
| 282 | if (!mtdblk) | 282 | if (!mtdblk) |
| 283 | return -ENOMEM; | 283 | return -ENOMEM; |
| 284 | 284 | ||
| 285 | memset(mtdblk, 0, sizeof(*mtdblk)); | ||
| 286 | mtdblk->count = 1; | 285 | mtdblk->count = 1; |
| 287 | mtdblk->mtd = mtd; | 286 | mtdblk->mtd = mtd; |
| 288 | 287 | ||
| @@ -339,13 +338,11 @@ static int mtdblock_flush(struct mtd_blktrans_dev *dev) | |||
| 339 | 338 | ||
| 340 | static void mtdblock_add_mtd(struct mtd_blktrans_ops *tr, struct mtd_info *mtd) | 339 | static void mtdblock_add_mtd(struct mtd_blktrans_ops *tr, struct mtd_info *mtd) |
| 341 | { | 340 | { |
| 342 | struct mtd_blktrans_dev *dev = kmalloc(sizeof(*dev), GFP_KERNEL); | 341 | struct mtd_blktrans_dev *dev = kzalloc(sizeof(*dev), GFP_KERNEL); |
| 343 | 342 | ||
| 344 | if (!dev) | 343 | if (!dev) |
| 345 | return; | 344 | return; |
| 346 | 345 | ||
| 347 | memset(dev, 0, sizeof(*dev)); | ||
| 348 | |||
| 349 | dev->mtd = mtd; | 346 | dev->mtd = mtd; |
| 350 | dev->devnum = mtd->index; | 347 | dev->devnum = mtd->index; |
| 351 | 348 | ||
diff --git a/drivers/mtd/mtdblock_ro.c b/drivers/mtd/mtdblock_ro.c index 642ccc66f283..f79dbb49b1a2 100644 --- a/drivers/mtd/mtdblock_ro.c +++ b/drivers/mtd/mtdblock_ro.c | |||
| @@ -33,13 +33,11 @@ static int mtdblock_writesect(struct mtd_blktrans_dev *dev, | |||
| 33 | 33 | ||
| 34 | static void mtdblock_add_mtd(struct mtd_blktrans_ops *tr, struct mtd_info *mtd) | 34 | static void mtdblock_add_mtd(struct mtd_blktrans_ops *tr, struct mtd_info *mtd) |
| 35 | { | 35 | { |
| 36 | struct mtd_blktrans_dev *dev = kmalloc(sizeof(*dev), GFP_KERNEL); | 36 | struct mtd_blktrans_dev *dev = kzalloc(sizeof(*dev), GFP_KERNEL); |
| 37 | 37 | ||
| 38 | if (!dev) | 38 | if (!dev) |
| 39 | return; | 39 | return; |
| 40 | 40 | ||
| 41 | memset(dev, 0, sizeof(*dev)); | ||
| 42 | |||
| 43 | dev->mtd = mtd; | 41 | dev->mtd = mtd; |
| 44 | dev->devnum = mtd->index; | 42 | dev->devnum = mtd->index; |
| 45 | 43 | ||
diff --git a/drivers/mtd/mtdchar.c b/drivers/mtd/mtdchar.c index 07618f51d969..7c4adc641328 100644 --- a/drivers/mtd/mtdchar.c +++ b/drivers/mtd/mtdchar.c | |||
| @@ -431,7 +431,7 @@ static int mtd_ioctl(struct inode *inode, struct file *file, | |||
| 431 | if(!(file->f_mode & 2)) | 431 | if(!(file->f_mode & 2)) |
| 432 | return -EPERM; | 432 | return -EPERM; |
| 433 | 433 | ||
| 434 | erase=kmalloc(sizeof(struct erase_info),GFP_KERNEL); | 434 | erase=kzalloc(sizeof(struct erase_info),GFP_KERNEL); |
| 435 | if (!erase) | 435 | if (!erase) |
| 436 | ret = -ENOMEM; | 436 | ret = -ENOMEM; |
| 437 | else { | 437 | else { |
| @@ -440,7 +440,6 @@ static int mtd_ioctl(struct inode *inode, struct file *file, | |||
| 440 | 440 | ||
| 441 | init_waitqueue_head(&waitq); | 441 | init_waitqueue_head(&waitq); |
| 442 | 442 | ||
| 443 | memset (erase,0,sizeof(struct erase_info)); | ||
| 444 | if (copy_from_user(&erase->addr, argp, | 443 | if (copy_from_user(&erase->addr, argp, |
| 445 | sizeof(struct erase_info_user))) { | 444 | sizeof(struct erase_info_user))) { |
| 446 | kfree(erase); | 445 | kfree(erase); |
diff --git a/drivers/mtd/mtdconcat.c b/drivers/mtd/mtdconcat.c index cf927a8803e7..ec51483b1c51 100644 --- a/drivers/mtd/mtdconcat.c +++ b/drivers/mtd/mtdconcat.c | |||
| @@ -708,14 +708,13 @@ struct mtd_info *mtd_concat_create(struct mtd_info *subdev[], /* subdevices to c | |||
| 708 | 708 | ||
| 709 | /* allocate the device structure */ | 709 | /* allocate the device structure */ |
| 710 | size = SIZEOF_STRUCT_MTD_CONCAT(num_devs); | 710 | size = SIZEOF_STRUCT_MTD_CONCAT(num_devs); |
| 711 | concat = kmalloc(size, GFP_KERNEL); | 711 | concat = kzalloc(size, GFP_KERNEL); |
| 712 | if (!concat) { | 712 | if (!concat) { |
| 713 | printk | 713 | printk |
| 714 | ("memory allocation error while creating concatenated device \"%s\"\n", | 714 | ("memory allocation error while creating concatenated device \"%s\"\n", |
| 715 | name); | 715 | name); |
| 716 | return NULL; | 716 | return NULL; |
| 717 | } | 717 | } |
| 718 | memset(concat, 0, size); | ||
| 719 | concat->subdev = (struct mtd_info **) (concat + 1); | 718 | concat->subdev = (struct mtd_info **) (concat + 1); |
| 720 | 719 | ||
| 721 | /* | 720 | /* |
diff --git a/drivers/mtd/mtdpart.c b/drivers/mtd/mtdpart.c index a20f75fd8d61..89692f898ef4 100644 --- a/drivers/mtd/mtdpart.c +++ b/drivers/mtd/mtdpart.c | |||
| @@ -323,14 +323,13 @@ int add_mtd_partitions(struct mtd_info *master, | |||
| 323 | for (i = 0; i < nbparts; i++) { | 323 | for (i = 0; i < nbparts; i++) { |
| 324 | 324 | ||
| 325 | /* allocate the partition structure */ | 325 | /* allocate the partition structure */ |
| 326 | slave = kmalloc (sizeof(*slave), GFP_KERNEL); | 326 | slave = kzalloc (sizeof(*slave), GFP_KERNEL); |
| 327 | if (!slave) { | 327 | if (!slave) { |
| 328 | printk ("memory allocation error while creating partitions for \"%s\"\n", | 328 | printk ("memory allocation error while creating partitions for \"%s\"\n", |
| 329 | master->name); | 329 | master->name); |
| 330 | del_mtd_partitions(master); | 330 | del_mtd_partitions(master); |
| 331 | return -ENOMEM; | 331 | return -ENOMEM; |
| 332 | } | 332 | } |
| 333 | memset(slave, 0, sizeof(*slave)); | ||
| 334 | list_add(&slave->list, &mtd_partitions); | 333 | list_add(&slave->list, &mtd_partitions); |
| 335 | 334 | ||
| 336 | /* set up the MTD object for this partition */ | 335 | /* set up the MTD object for this partition */ |
diff --git a/drivers/mtd/nand/diskonchip.c b/drivers/mtd/nand/diskonchip.c index 6107f532855b..12608c13cce5 100644 --- a/drivers/mtd/nand/diskonchip.c +++ b/drivers/mtd/nand/diskonchip.c | |||
| @@ -1635,13 +1635,12 @@ static int __init doc_probe(unsigned long physadr) | |||
| 1635 | 1635 | ||
| 1636 | len = sizeof(struct mtd_info) + | 1636 | len = sizeof(struct mtd_info) + |
| 1637 | sizeof(struct nand_chip) + sizeof(struct doc_priv) + (2 * sizeof(struct nand_bbt_descr)); | 1637 | sizeof(struct nand_chip) + sizeof(struct doc_priv) + (2 * sizeof(struct nand_bbt_descr)); |
| 1638 | mtd = kmalloc(len, GFP_KERNEL); | 1638 | mtd = kzalloc(len, GFP_KERNEL); |
| 1639 | if (!mtd) { | 1639 | if (!mtd) { |
| 1640 | printk(KERN_ERR "DiskOnChip kmalloc (%d bytes) failed!\n", len); | 1640 | printk(KERN_ERR "DiskOnChip kmalloc (%d bytes) failed!\n", len); |
| 1641 | ret = -ENOMEM; | 1641 | ret = -ENOMEM; |
| 1642 | goto fail; | 1642 | goto fail; |
| 1643 | } | 1643 | } |
| 1644 | memset(mtd, 0, len); | ||
| 1645 | 1644 | ||
| 1646 | nand = (struct nand_chip *) (mtd + 1); | 1645 | nand = (struct nand_chip *) (mtd + 1); |
| 1647 | doc = (struct doc_priv *) (nand + 1); | 1646 | doc = (struct doc_priv *) (nand + 1); |
diff --git a/drivers/mtd/nand/nand_bbt.c b/drivers/mtd/nand/nand_bbt.c index 4e74fe9af29e..5e121ceaa598 100644 --- a/drivers/mtd/nand/nand_bbt.c +++ b/drivers/mtd/nand/nand_bbt.c | |||
| @@ -960,14 +960,12 @@ int nand_scan_bbt(struct mtd_info *mtd, struct nand_bbt_descr *bd) | |||
| 960 | struct nand_bbt_descr *md = this->bbt_md; | 960 | struct nand_bbt_descr *md = this->bbt_md; |
| 961 | 961 | ||
| 962 | len = mtd->size >> (this->bbt_erase_shift + 2); | 962 | len = mtd->size >> (this->bbt_erase_shift + 2); |
| 963 | /* Allocate memory (2bit per block) */ | 963 | /* Allocate memory (2bit per block) and clear the memory bad block table */ |
| 964 | this->bbt = kmalloc(len, GFP_KERNEL); | 964 | this->bbt = kzalloc(len, GFP_KERNEL); |
| 965 | if (!this->bbt) { | 965 | if (!this->bbt) { |
| 966 | printk(KERN_ERR "nand_scan_bbt: Out of memory\n"); | 966 | printk(KERN_ERR "nand_scan_bbt: Out of memory\n"); |
| 967 | return -ENOMEM; | 967 | return -ENOMEM; |
| 968 | } | 968 | } |
| 969 | /* Clear the memory bad block table */ | ||
| 970 | memset(this->bbt, 0x00, len); | ||
| 971 | 969 | ||
| 972 | /* If no primary table decriptor is given, scan the device | 970 | /* If no primary table decriptor is given, scan the device |
| 973 | * to build a memory based bad block table | 971 | * to build a memory based bad block table |
diff --git a/drivers/mtd/nand/nandsim.c b/drivers/mtd/nand/nandsim.c index abebcab47631..3d39451ae8f5 100644 --- a/drivers/mtd/nand/nandsim.c +++ b/drivers/mtd/nand/nandsim.c | |||
| @@ -1511,14 +1511,12 @@ static int __init ns_init_module(void) | |||
| 1511 | } | 1511 | } |
| 1512 | 1512 | ||
| 1513 | /* Allocate and initialize mtd_info, nand_chip and nandsim structures */ | 1513 | /* Allocate and initialize mtd_info, nand_chip and nandsim structures */ |
| 1514 | nsmtd = kmalloc(sizeof(struct mtd_info) + sizeof(struct nand_chip) | 1514 | nsmtd = kzalloc(sizeof(struct mtd_info) + sizeof(struct nand_chip) |
| 1515 | + sizeof(struct nandsim), GFP_KERNEL); | 1515 | + sizeof(struct nandsim), GFP_KERNEL); |
| 1516 | if (!nsmtd) { | 1516 | if (!nsmtd) { |
| 1517 | NS_ERR("unable to allocate core structures.\n"); | 1517 | NS_ERR("unable to allocate core structures.\n"); |
| 1518 | return -ENOMEM; | 1518 | return -ENOMEM; |
| 1519 | } | 1519 | } |
| 1520 | memset(nsmtd, 0, sizeof(struct mtd_info) + sizeof(struct nand_chip) + | ||
| 1521 | sizeof(struct nandsim)); | ||
| 1522 | chip = (struct nand_chip *)(nsmtd + 1); | 1520 | chip = (struct nand_chip *)(nsmtd + 1); |
| 1523 | nsmtd->priv = (void *)chip; | 1521 | nsmtd->priv = (void *)chip; |
| 1524 | nand = (struct nandsim *)(chip + 1); | 1522 | nand = (struct nandsim *)(chip + 1); |
diff --git a/drivers/mtd/nftlcore.c b/drivers/mtd/nftlcore.c index f4d38546068f..4b1ba4fcfcd3 100644 --- a/drivers/mtd/nftlcore.c +++ b/drivers/mtd/nftlcore.c | |||
| @@ -57,13 +57,12 @@ static void nftl_add_mtd(struct mtd_blktrans_ops *tr, struct mtd_info *mtd) | |||
| 57 | 57 | ||
| 58 | DEBUG(MTD_DEBUG_LEVEL1, "NFTL: add_mtd for %s\n", mtd->name); | 58 | DEBUG(MTD_DEBUG_LEVEL1, "NFTL: add_mtd for %s\n", mtd->name); |
| 59 | 59 | ||
| 60 | nftl = kmalloc(sizeof(struct NFTLrecord), GFP_KERNEL); | 60 | nftl = kzalloc(sizeof(struct NFTLrecord), GFP_KERNEL); |
| 61 | 61 | ||
| 62 | if (!nftl) { | 62 | if (!nftl) { |
| 63 | printk(KERN_WARNING "NFTL: out of memory for data structures\n"); | 63 | printk(KERN_WARNING "NFTL: out of memory for data structures\n"); |
| 64 | return; | 64 | return; |
| 65 | } | 65 | } |
| 66 | memset(nftl, 0, sizeof(*nftl)); | ||
| 67 | 66 | ||
| 68 | nftl->mbd.mtd = mtd; | 67 | nftl->mbd.mtd = mtd; |
| 69 | nftl->mbd.devnum = -1; | 68 | nftl->mbd.devnum = -1; |
diff --git a/drivers/mtd/onenand/generic.c b/drivers/mtd/onenand/generic.c index af06a80f44de..53eb5632bdbb 100644 --- a/drivers/mtd/onenand/generic.c +++ b/drivers/mtd/onenand/generic.c | |||
| @@ -45,12 +45,10 @@ static int __devinit generic_onenand_probe(struct device *dev) | |||
| 45 | unsigned long size = res->end - res->start + 1; | 45 | unsigned long size = res->end - res->start + 1; |
| 46 | int err; | 46 | int err; |
| 47 | 47 | ||
| 48 | info = kmalloc(sizeof(struct onenand_info), GFP_KERNEL); | 48 | info = kzalloc(sizeof(struct onenand_info), GFP_KERNEL); |
| 49 | if (!info) | 49 | if (!info) |
| 50 | return -ENOMEM; | 50 | return -ENOMEM; |
| 51 | 51 | ||
| 52 | memset(info, 0, sizeof(struct onenand_info)); | ||
| 53 | |||
| 54 | if (!request_mem_region(res->start, size, dev->driver->name)) { | 52 | if (!request_mem_region(res->start, size, dev->driver->name)) { |
| 55 | err = -EBUSY; | 53 | err = -EBUSY; |
| 56 | goto out_free_info; | 54 | goto out_free_info; |
diff --git a/drivers/mtd/onenand/onenand_bbt.c b/drivers/mtd/onenand/onenand_bbt.c index 1b00dac3d7d6..e3822c1cdb8d 100644 --- a/drivers/mtd/onenand/onenand_bbt.c +++ b/drivers/mtd/onenand/onenand_bbt.c | |||
| @@ -177,14 +177,12 @@ int onenand_scan_bbt(struct mtd_info *mtd, struct nand_bbt_descr *bd) | |||
| 177 | int len, ret = 0; | 177 | int len, ret = 0; |
| 178 | 178 | ||
| 179 | len = mtd->size >> (this->erase_shift + 2); | 179 | len = mtd->size >> (this->erase_shift + 2); |
| 180 | /* Allocate memory (2bit per block) */ | 180 | /* Allocate memory (2bit per block) and clear the memory bad block table */ |
| 181 | bbm->bbt = kmalloc(len, GFP_KERNEL); | 181 | bbm->bbt = kzalloc(len, GFP_KERNEL); |
| 182 | if (!bbm->bbt) { | 182 | if (!bbm->bbt) { |
| 183 | printk(KERN_ERR "onenand_scan_bbt: Out of memory\n"); | 183 | printk(KERN_ERR "onenand_scan_bbt: Out of memory\n"); |
| 184 | return -ENOMEM; | 184 | return -ENOMEM; |
| 185 | } | 185 | } |
| 186 | /* Clear the memory bad block table */ | ||
| 187 | memset(bbm->bbt, 0x00, len); | ||
| 188 | 186 | ||
| 189 | /* Set the bad block position */ | 187 | /* Set the bad block position */ |
| 190 | bbm->badblockpos = ONENAND_BADBLOCK_POS; | 188 | bbm->badblockpos = ONENAND_BADBLOCK_POS; |
| @@ -230,14 +228,12 @@ int onenand_default_bbt(struct mtd_info *mtd) | |||
| 230 | struct onenand_chip *this = mtd->priv; | 228 | struct onenand_chip *this = mtd->priv; |
| 231 | struct bbm_info *bbm; | 229 | struct bbm_info *bbm; |
| 232 | 230 | ||
| 233 | this->bbm = kmalloc(sizeof(struct bbm_info), GFP_KERNEL); | 231 | this->bbm = kzalloc(sizeof(struct bbm_info), GFP_KERNEL); |
| 234 | if (!this->bbm) | 232 | if (!this->bbm) |
| 235 | return -ENOMEM; | 233 | return -ENOMEM; |
| 236 | 234 | ||
| 237 | bbm = this->bbm; | 235 | bbm = this->bbm; |
| 238 | 236 | ||
| 239 | memset(bbm, 0, sizeof(struct bbm_info)); | ||
| 240 | |||
| 241 | /* 1KB page has same configuration as 2KB page */ | 237 | /* 1KB page has same configuration as 2KB page */ |
| 242 | if (!bbm->badblock_pattern) | 238 | if (!bbm->badblock_pattern) |
| 243 | bbm->badblock_pattern = &largepage_memorybased; | 239 | bbm->badblock_pattern = &largepage_memorybased; |
diff --git a/drivers/mtd/redboot.c b/drivers/mtd/redboot.c index 5b58523e4d4e..4b277211e27b 100644 --- a/drivers/mtd/redboot.c +++ b/drivers/mtd/redboot.c | |||
| @@ -165,15 +165,13 @@ static int parse_redboot_partitions(struct mtd_info *master, | |||
| 165 | } | 165 | } |
| 166 | } | 166 | } |
| 167 | #endif | 167 | #endif |
| 168 | parts = kmalloc(sizeof(*parts)*nrparts + nulllen + namelen, GFP_KERNEL); | 168 | parts = kzalloc(sizeof(*parts)*nrparts + nulllen + namelen, GFP_KERNEL); |
| 169 | 169 | ||
| 170 | if (!parts) { | 170 | if (!parts) { |
| 171 | ret = -ENOMEM; | 171 | ret = -ENOMEM; |
| 172 | goto out; | 172 | goto out; |
| 173 | } | 173 | } |
| 174 | 174 | ||
| 175 | memset(parts, 0, sizeof(*parts)*nrparts + nulllen + namelen); | ||
| 176 | |||
| 177 | nullname = (char *)&parts[nrparts]; | 175 | nullname = (char *)&parts[nrparts]; |
| 178 | #ifdef CONFIG_MTD_REDBOOT_PARTS_UNALLOCATED | 176 | #ifdef CONFIG_MTD_REDBOOT_PARTS_UNALLOCATED |
| 179 | if (nulllen > 0) { | 177 | if (nulllen > 0) { |
