Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[MTD] replace kmalloc+memset with kzalloc

Signed-off-by: Yan Burman <yan_952@hotmail.com>
Signed-off-by: David Woodhouse <dwmw2@infradead.org>

authored by

Burman Yan and committed by
David Woodhouse
95b93a0c 998a43e7

+53 -125
+1 -2
arch/ppc/platforms/ev64360.c
··· 358 358 359 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 362 GFP_KERNEL)) == NULL) { 363 363 364 364 printk(KERN_WARNING "Can't alloc MTD partition table\n"); 365 365 return -ENOMEM; 366 366 } 367 - memset(ptbl, 0, ptbl_entries * sizeof(struct mtd_partition)); 368 367 369 368 ptbl[0].name = "reserved"; 370 369 ptbl[0].offset = 0;
+1 -2
drivers/mtd/afs.c
··· 207 207 if (!sz) 208 208 return ret; 209 209 210 - parts = kmalloc(sz, GFP_KERNEL); 210 + parts = kzalloc(sz, GFP_KERNEL); 211 211 if (!parts) 212 212 return -ENOMEM; 213 213 214 - memset(parts, 0, sz); 215 214 str = (char *)(parts + idx); 216 215 217 216 /*
+1 -2
drivers/mtd/chips/amd_flash.c
··· 643 643 int reg_idx; 644 644 int offset; 645 645 646 - mtd = (struct mtd_info*)kmalloc(sizeof(*mtd), GFP_KERNEL); 646 + mtd = kzalloc(sizeof(*mtd), GFP_KERNEL); 647 647 if (!mtd) { 648 648 printk(KERN_WARNING 649 649 "%s: kmalloc failed for info structure\n", map->name); 650 650 return NULL; 651 651 } 652 - memset(mtd, 0, sizeof(*mtd)); 653 652 mtd->priv = map; 654 653 655 654 memset(&temp, 0, sizeof(temp));
+1 -2
drivers/mtd/chips/cfi_cmdset_0001.c
··· 337 337 struct mtd_info *mtd; 338 338 int i; 339 339 340 - mtd = kmalloc(sizeof(*mtd), GFP_KERNEL); 340 + mtd = kzalloc(sizeof(*mtd), GFP_KERNEL); 341 341 if (!mtd) { 342 342 printk(KERN_ERR "Failed to allocate memory for MTD device\n"); 343 343 return NULL; 344 344 } 345 - memset(mtd, 0, sizeof(*mtd)); 346 345 mtd->priv = map; 347 346 mtd->type = MTD_NORFLASH; 348 347
+1 -2
drivers/mtd/chips/cfi_cmdset_0002.c
··· 257 257 struct mtd_info *mtd; 258 258 int i; 259 259 260 - mtd = kmalloc(sizeof(*mtd), GFP_KERNEL); 260 + mtd = kzalloc(sizeof(*mtd), GFP_KERNEL); 261 261 if (!mtd) { 262 262 printk(KERN_WARNING "Failed to allocate memory for MTD device\n"); 263 263 return NULL; 264 264 } 265 - memset(mtd, 0, sizeof(*mtd)); 266 265 mtd->priv = map; 267 266 mtd->type = MTD_NORFLASH; 268 267
+1 -2
drivers/mtd/chips/cfi_cmdset_0020.c
··· 172 172 int i,j; 173 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 176 //printk(KERN_DEBUG "number of CFI chips: %d\n", cfi->numchips); 177 177 178 178 if (!mtd) { ··· 181 181 return NULL; 182 182 } 183 183 184 - memset(mtd, 0, sizeof(*mtd)); 185 184 mtd->priv = map; 186 185 mtd->type = MTD_NORFLASH; 187 186 mtd->size = devsize * cfi->numchips;
+1 -2
drivers/mtd/chips/gen_probe.c
··· 113 113 } 114 114 115 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 117 if (!chip_map) { 118 118 printk(KERN_WARNING "%s: kmalloc failed for CFI chip map\n", map->name); 119 119 kfree(cfi.cfiq); 120 120 return NULL; 121 121 } 122 - memset (chip_map, 0, mapsize); 123 122 124 123 set_bit(0, chip_map); /* Mark first chip valid */ 125 124
+1 -2
drivers/mtd/chips/jedec.c
··· 116 116 char Part[200]; 117 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 120 if (!MTD) 121 121 return NULL; 122 122 123 - memset(MTD, 0, sizeof(struct mtd_info) + sizeof(struct jedec_private)); 124 123 priv = (struct jedec_private *)&MTD[1]; 125 124 126 125 my_bank_size = map->size;
+1 -3
drivers/mtd/chips/map_absent.c
··· 47 47 { 48 48 struct mtd_info *mtd; 49 49 50 - mtd = kmalloc(sizeof(*mtd), GFP_KERNEL); 50 + mtd = kzalloc(sizeof(*mtd), GFP_KERNEL); 51 51 if (!mtd) { 52 52 return NULL; 53 53 } 54 - 55 - memset(mtd, 0, sizeof(*mtd)); 56 54 57 55 map->fldrv = &map_absent_chipdrv; 58 56 mtd->priv = map;
+1 -3
drivers/mtd/chips/map_ram.c
··· 55 55 #endif 56 56 /* OK. It seems to be RAM. */ 57 57 58 - mtd = kmalloc(sizeof(*mtd), GFP_KERNEL); 58 + mtd = kzalloc(sizeof(*mtd), GFP_KERNEL); 59 59 if (!mtd) 60 60 return NULL; 61 - 62 - memset(mtd, 0, sizeof(*mtd)); 63 61 64 62 map->fldrv = &mapram_chipdrv; 65 63 mtd->priv = map;
+1 -3
drivers/mtd/chips/map_rom.c
··· 31 31 { 32 32 struct mtd_info *mtd; 33 33 34 - mtd = kmalloc(sizeof(*mtd), GFP_KERNEL); 34 + mtd = kzalloc(sizeof(*mtd), GFP_KERNEL); 35 35 if (!mtd) 36 36 return NULL; 37 - 38 - memset(mtd, 0, sizeof(*mtd)); 39 37 40 38 map->fldrv = &maprom_chipdrv; 41 39 mtd->priv = map;
+2 -5
drivers/mtd/chips/sharp.c
··· 112 112 struct sharp_info *sharp = NULL; 113 113 int width; 114 114 115 - mtd = kmalloc(sizeof(*mtd), GFP_KERNEL); 115 + mtd = kzalloc(sizeof(*mtd), GFP_KERNEL); 116 116 if(!mtd) 117 117 return NULL; 118 118 119 - sharp = kmalloc(sizeof(*sharp), GFP_KERNEL); 119 + sharp = kzalloc(sizeof(*sharp), GFP_KERNEL); 120 120 if(!sharp) { 121 121 kfree(mtd); 122 122 return NULL; 123 123 } 124 - 125 - memset(mtd, 0, sizeof(*mtd)); 126 124 127 125 width = sharp_probe_map(map,mtd); 128 126 if(!width){ ··· 141 143 mtd->writesize = 1; 142 144 mtd->name = map->name; 143 145 144 - memset(sharp, 0, sizeof(*sharp)); 145 146 sharp->chipshift = 23; 146 147 sharp->numchips = 1; 147 148 sharp->chips[0].start = 0;
+1 -2
drivers/mtd/cmdlinepart.c
··· 163 163 *num_parts = this_part + 1; 164 164 alloc_size = *num_parts * sizeof(struct mtd_partition) + 165 165 extra_mem_size; 166 - parts = kmalloc(alloc_size, GFP_KERNEL); 166 + parts = kzalloc(alloc_size, GFP_KERNEL); 167 167 if (!parts) 168 168 { 169 169 printk(KERN_ERR ERRP "out of memory\n"); 170 170 return NULL; 171 171 } 172 - memset(parts, 0, alloc_size); 173 172 extra_mem = (unsigned char *)(parts + *num_parts); 174 173 } 175 174 /* enter this partition (offset will be calculated later if it is zero at this point) */
+1 -2
drivers/mtd/devices/block2mtd.c
··· 295 295 if (!devname) 296 296 return NULL; 297 297 298 - dev = kmalloc(sizeof(struct block2mtd_dev), GFP_KERNEL); 298 + dev = kzalloc(sizeof(struct block2mtd_dev), GFP_KERNEL); 299 299 if (!dev) 300 300 return NULL; 301 - memset(dev, 0, sizeof(*dev)); 302 301 303 302 /* Get a handle on the device */ 304 303 bdev = open_bdev_excl(devname, O_RDWR, NULL);
+6 -12
drivers/mtd/devices/ms02-nv.c
··· 131 131 int ret = -ENODEV; 132 132 133 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 135 if (!mod_res) 136 136 return -ENOMEM; 137 137 138 - memset(mod_res, 0, sizeof(*mod_res)); 139 138 mod_res->name = ms02nv_name; 140 139 mod_res->start = addr; 141 140 mod_res->end = addr + MS02NV_SLOT_SIZE - 1; ··· 152 153 } 153 154 154 155 ret = -ENOMEM; 155 - mtd = kmalloc(sizeof(*mtd), GFP_KERNEL); 156 + mtd = kzalloc(sizeof(*mtd), GFP_KERNEL); 156 157 if (!mtd) 157 158 goto err_out_mod_res_rel; 158 - memset(mtd, 0, sizeof(*mtd)); 159 - mp = kmalloc(sizeof(*mp), GFP_KERNEL); 159 + mp = kzalloc(sizeof(*mp), GFP_KERNEL); 160 160 if (!mp) 161 161 goto err_out_mtd; 162 - memset(mp, 0, sizeof(*mp)); 163 162 164 163 mtd->priv = mp; 165 164 mp->resource.module = mod_res; 166 165 167 166 /* Firmware's diagnostic NVRAM area. */ 168 - diag_res = kmalloc(sizeof(*diag_res), GFP_KERNEL); 167 + diag_res = kzalloc(sizeof(*diag_res), GFP_KERNEL); 169 168 if (!diag_res) 170 169 goto err_out_mp; 171 170 172 - memset(diag_res, 0, sizeof(*diag_res)); 173 171 diag_res->name = ms02nv_res_diag_ram; 174 172 diag_res->start = addr; 175 173 diag_res->end = addr + MS02NV_RAM - 1; ··· 176 180 mp->resource.diag_ram = diag_res; 177 181 178 182 /* User-available general-purpose NVRAM area. */ 179 - user_res = kmalloc(sizeof(*user_res), GFP_KERNEL); 183 + user_res = kzalloc(sizeof(*user_res), GFP_KERNEL); 180 184 if (!user_res) 181 185 goto err_out_diag_res; 182 186 183 - memset(user_res, 0, sizeof(*user_res)); 184 187 user_res->name = ms02nv_res_user_ram; 185 188 user_res->start = addr + MS02NV_RAM; 186 189 user_res->end = addr + size - 1; ··· 189 194 mp->resource.user_ram = user_res; 190 195 191 196 /* Control and status register. */ 192 - csr_res = kmalloc(sizeof(*csr_res), GFP_KERNEL); 197 + csr_res = kzalloc(sizeof(*csr_res), GFP_KERNEL); 193 198 if (!csr_res) 194 199 goto err_out_user_res; 195 200 196 - memset(csr_res, 0, sizeof(*csr_res)); 197 201 csr_res->name = ms02nv_res_csr; 198 202 csr_res->start = addr + MS02NV_CSR; 199 203 csr_res->end = addr + MS02NV_CSR + 3;
+1 -3
drivers/mtd/devices/phram.c
··· 126 126 struct phram_mtd_list *new; 127 127 int ret = -ENOMEM; 128 128 129 - new = kmalloc(sizeof(*new), GFP_KERNEL); 129 + new = kzalloc(sizeof(*new), GFP_KERNEL); 130 130 if (!new) 131 131 goto out0; 132 - 133 - memset(new, 0, sizeof(*new)); 134 132 135 133 ret = -EIO; 136 134 new->mtd.priv = ioremap(start, len);
+2 -5
drivers/mtd/devices/slram.c
··· 168 168 E("slram: Cannot allocate new MTD device.\n"); 169 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 172 (*curmtd)->next = NULL; 173 173 174 174 if ((*curmtd)->mtdinfo) { 175 - memset((char *)(*curmtd)->mtdinfo, 0, sizeof(struct mtd_info)); 176 175 (*curmtd)->mtdinfo->priv = 177 - kmalloc(sizeof(slram_priv_t), GFP_KERNEL); 176 + kzalloc(sizeof(slram_priv_t), GFP_KERNEL); 178 177 179 178 if (!(*curmtd)->mtdinfo->priv) { 180 179 kfree((*curmtd)->mtdinfo); 181 180 (*curmtd)->mtdinfo = NULL; 182 - } else { 183 - memset((*curmtd)->mtdinfo->priv,0,sizeof(slram_priv_t)); 184 181 } 185 182 } 186 183
+1 -3
drivers/mtd/ftl.c
··· 1033 1033 { 1034 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 1038 if (!partition) { 1039 1039 printk(KERN_WARNING "No memory to scan for FTL on %s\n", 1040 1040 mtd->name); 1041 1041 return; 1042 1042 } 1043 - 1044 - memset(partition, 0, sizeof(partition_t)); 1045 1043 1046 1044 partition->mbd.mtd = mtd; 1047 1045
+1 -2
drivers/mtd/inftlcore.c
··· 67 67 68 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 72 if (!inftl) { 73 73 printk(KERN_WARNING "INFTL: Out of memory for data structures\n"); 74 74 return; 75 75 } 76 - memset(inftl, 0, sizeof(*inftl)); 77 76 78 77 inftl->mbd.mtd = mtd; 79 78 inftl->mbd.devnum = -1;
+1 -2
drivers/mtd/maps/ceiva.c
··· 122 122 /* 123 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 126 if (!maps) 127 127 return -ENOMEM; 128 - memset(maps, 0, sizeof(struct map_info) * nr); 129 128 /* 130 129 * Claim and then map the memory regions. 131 130 */
+1 -3
drivers/mtd/maps/integrator-flash.c
··· 75 75 int err; 76 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 79 if (!info) { 80 80 err = -ENOMEM; 81 81 goto out; 82 82 } 83 - 84 - memset(info, 0, sizeof(struct armflash_info)); 85 83 86 84 info->plat = plat; 87 85 if (plat && plat->init) {
+1 -3
drivers/mtd/maps/omap_nor.c
··· 78 78 struct resource *res = pdev->resource; 79 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 82 if (!info) 83 83 return -ENOMEM; 84 - 85 - memset(info, 0, sizeof(struct omapflash_info)); 86 84 87 85 if (!request_mem_region(res->start, size, "flash")) { 88 86 err = -EBUSY;
+1 -2
drivers/mtd/maps/pcmciamtd.c
··· 735 735 struct pcmciamtd_dev *dev; 736 736 737 737 /* Create new memory card device */ 738 - dev = kmalloc(sizeof(*dev), GFP_KERNEL); 738 + dev = kzalloc(sizeof(*dev), GFP_KERNEL); 739 739 if (!dev) return -ENOMEM; 740 740 DEBUG(1, "dev=0x%p", dev); 741 741 742 - memset(dev, 0, sizeof(*dev)); 743 742 dev->p_dev = link; 744 743 link->priv = dev; 745 744
+1 -2
drivers/mtd/maps/physmap.c
··· 92 92 (unsigned long long)(dev->resource->end - dev->resource->start + 1), 93 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 96 if (info == NULL) { 97 97 err = -ENOMEM; 98 98 goto err_out; 99 99 } 100 - memset(info, 0, sizeof(*info)); 101 100 102 101 platform_set_drvdata(dev, info); 103 102
+1 -2
drivers/mtd/maps/plat-ram.c
··· 147 147 148 148 pdata = pdev->dev.platform_data; 149 149 150 - info = kmalloc(sizeof(*info), GFP_KERNEL); 150 + info = kzalloc(sizeof(*info), GFP_KERNEL); 151 151 if (info == NULL) { 152 152 dev_err(&pdev->dev, "no memory for flash info\n"); 153 153 err = -ENOMEM; 154 154 goto exit_error; 155 155 } 156 156 157 - memset(info, 0, sizeof(*info)); 158 157 platform_set_drvdata(pdev, info); 159 158 160 159 info->dev = &pdev->dev;
+1 -3
drivers/mtd/maps/sa1100-flash.c
··· 273 273 /* 274 274 * Allocate the map_info structs in one go. 275 275 */ 276 - info = kmalloc(size, GFP_KERNEL); 276 + info = kzalloc(size, GFP_KERNEL); 277 277 if (!info) { 278 278 ret = -ENOMEM; 279 279 goto out; 280 280 } 281 - 282 - memset(info, 0, size); 283 281 284 282 if (plat->init) { 285 283 ret = plat->init();
+2 -6
drivers/mtd/maps/tqm834x.c
··· 132 132 133 133 pr_debug("%s: chip probing count %d\n", __FUNCTION__, idx); 134 134 135 - map_banks[idx] = 136 - (struct map_info *)kmalloc(sizeof(struct map_info), 137 - GFP_KERNEL); 135 + map_banks[idx] = kzalloc(sizeof(struct map_info), GFP_KERNEL); 138 136 if (map_banks[idx] == NULL) { 139 137 ret = -ENOMEM; 140 138 goto error_mem; 141 139 } 142 - memset((void *)map_banks[idx], 0, sizeof(struct map_info)); 143 - map_banks[idx]->name = (char *)kmalloc(16, GFP_KERNEL); 140 + map_banks[idx]->name = kzalloc(16, GFP_KERNEL); 144 141 if (map_banks[idx]->name == NULL) { 145 142 ret = -ENOMEM; 146 143 goto error_mem; 147 144 } 148 - memset((void *)map_banks[idx]->name, 0, 16); 149 145 150 146 sprintf(map_banks[idx]->name, "TQM834x-%d", idx); 151 147 map_banks[idx]->size = flash_size;
+1 -2
drivers/mtd/maps/tqm8xxl.c
··· 134 134 135 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 138 if(map_banks[idx] == NULL) { 139 139 ret = -ENOMEM; 140 140 /* FIXME: What if some MTD devices were probed already? */ 141 141 goto error_mem; 142 142 } 143 143 144 - memset((void *)map_banks[idx], 0, sizeof(struct map_info)); 145 144 map_banks[idx]->name = (char *)kmalloc(16, GFP_KERNEL); 146 145 147 146 if (!map_banks[idx]->name) {
+1 -3
drivers/mtd/mtd_blkdevs.c
··· 373 373 if (!blktrans_notifier.list.next) 374 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 377 if (!tr->blkcore_priv) 378 378 return -ENOMEM; 379 - 380 - memset(tr->blkcore_priv, 0, sizeof(*tr->blkcore_priv)); 381 379 382 380 mutex_lock(&mtd_table_mutex); 383 381
+2 -5
drivers/mtd/mtdblock.c
··· 278 278 } 279 279 280 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 282 if (!mtdblk) 283 283 return -ENOMEM; 284 284 285 - memset(mtdblk, 0, sizeof(*mtdblk)); 286 285 mtdblk->count = 1; 287 286 mtdblk->mtd = mtd; 288 287 ··· 338 339 339 340 static void mtdblock_add_mtd(struct mtd_blktrans_ops *tr, struct mtd_info *mtd) 340 341 { 341 - struct mtd_blktrans_dev *dev = kmalloc(sizeof(*dev), GFP_KERNEL); 342 + struct mtd_blktrans_dev *dev = kzalloc(sizeof(*dev), GFP_KERNEL); 342 343 343 344 if (!dev) 344 345 return; 345 - 346 - memset(dev, 0, sizeof(*dev)); 347 346 348 347 dev->mtd = mtd; 349 348 dev->devnum = mtd->index;
+1 -3
drivers/mtd/mtdblock_ro.c
··· 33 33 34 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 38 if (!dev) 39 39 return; 40 - 41 - memset(dev, 0, sizeof(*dev)); 42 40 43 41 dev->mtd = mtd; 44 42 dev->devnum = mtd->index;
+1 -2
drivers/mtd/mtdchar.c
··· 431 431 if(!(file->f_mode & 2)) 432 432 return -EPERM; 433 433 434 - erase=kmalloc(sizeof(struct erase_info),GFP_KERNEL); 434 + erase=kzalloc(sizeof(struct erase_info),GFP_KERNEL); 435 435 if (!erase) 436 436 ret = -ENOMEM; 437 437 else { ··· 440 440 441 441 init_waitqueue_head(&waitq); 442 442 443 - memset (erase,0,sizeof(struct erase_info)); 444 443 if (copy_from_user(&erase->addr, argp, 445 444 sizeof(struct erase_info_user))) { 446 445 kfree(erase);
+1 -2
drivers/mtd/mtdconcat.c
··· 708 708 709 709 /* allocate the device structure */ 710 710 size = SIZEOF_STRUCT_MTD_CONCAT(num_devs); 711 - concat = kmalloc(size, GFP_KERNEL); 711 + concat = kzalloc(size, GFP_KERNEL); 712 712 if (!concat) { 713 713 printk 714 714 ("memory allocation error while creating concatenated device \"%s\"\n", 715 715 name); 716 716 return NULL; 717 717 } 718 - memset(concat, 0, size); 719 718 concat->subdev = (struct mtd_info **) (concat + 1); 720 719 721 720 /*
+1 -2
drivers/mtd/mtdpart.c
··· 323 323 for (i = 0; i < nbparts; i++) { 324 324 325 325 /* allocate the partition structure */ 326 - slave = kmalloc (sizeof(*slave), GFP_KERNEL); 326 + slave = kzalloc (sizeof(*slave), GFP_KERNEL); 327 327 if (!slave) { 328 328 printk ("memory allocation error while creating partitions for \"%s\"\n", 329 329 master->name); 330 330 del_mtd_partitions(master); 331 331 return -ENOMEM; 332 332 } 333 - memset(slave, 0, sizeof(*slave)); 334 333 list_add(&slave->list, &mtd_partitions); 335 334 336 335 /* set up the MTD object for this partition */
+1 -2
drivers/mtd/nand/diskonchip.c
··· 1635 1635 1636 1636 len = sizeof(struct mtd_info) + 1637 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 1639 if (!mtd) { 1640 1640 printk(KERN_ERR "DiskOnChip kmalloc (%d bytes) failed!\n", len); 1641 1641 ret = -ENOMEM; 1642 1642 goto fail; 1643 1643 } 1644 - memset(mtd, 0, len); 1645 1644 1646 1645 nand = (struct nand_chip *) (mtd + 1); 1647 1646 doc = (struct doc_priv *) (nand + 1);
+2 -4
drivers/mtd/nand/nand_bbt.c
··· 960 960 struct nand_bbt_descr *md = this->bbt_md; 961 961 962 962 len = mtd->size >> (this->bbt_erase_shift + 2); 963 - /* Allocate memory (2bit per block) */ 964 - this->bbt = kmalloc(len, GFP_KERNEL); 963 + /* Allocate memory (2bit per block) and clear the memory bad block table */ 964 + this->bbt = kzalloc(len, GFP_KERNEL); 965 965 if (!this->bbt) { 966 966 printk(KERN_ERR "nand_scan_bbt: Out of memory\n"); 967 967 return -ENOMEM; 968 968 } 969 - /* Clear the memory bad block table */ 970 - memset(this->bbt, 0x00, len); 971 969 972 970 /* If no primary table decriptor is given, scan the device 973 971 * to build a memory based bad block table
+1 -3
drivers/mtd/nand/nandsim.c
··· 1511 1511 } 1512 1512 1513 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 1515 + sizeof(struct nandsim), GFP_KERNEL); 1516 1516 if (!nsmtd) { 1517 1517 NS_ERR("unable to allocate core structures.\n"); 1518 1518 return -ENOMEM; 1519 1519 } 1520 - memset(nsmtd, 0, sizeof(struct mtd_info) + sizeof(struct nand_chip) + 1521 - sizeof(struct nandsim)); 1522 1520 chip = (struct nand_chip *)(nsmtd + 1); 1523 1521 nsmtd->priv = (void *)chip; 1524 1522 nand = (struct nandsim *)(chip + 1);
+1 -2
drivers/mtd/nftlcore.c
··· 57 57 58 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 62 if (!nftl) { 63 63 printk(KERN_WARNING "NFTL: out of memory for data structures\n"); 64 64 return; 65 65 } 66 - memset(nftl, 0, sizeof(*nftl)); 67 66 68 67 nftl->mbd.mtd = mtd; 69 68 nftl->mbd.devnum = -1;
+1 -3
drivers/mtd/onenand/generic.c
··· 45 45 unsigned long size = res->end - res->start + 1; 46 46 int err; 47 47 48 - info = kmalloc(sizeof(struct onenand_info), GFP_KERNEL); 48 + info = kzalloc(sizeof(struct onenand_info), GFP_KERNEL); 49 49 if (!info) 50 50 return -ENOMEM; 51 - 52 - memset(info, 0, sizeof(struct onenand_info)); 53 51 54 52 if (!request_mem_region(res->start, size, dev->driver->name)) { 55 53 err = -EBUSY;
+3 -7
drivers/mtd/onenand/onenand_bbt.c
··· 177 177 int len, ret = 0; 178 178 179 179 len = mtd->size >> (this->erase_shift + 2); 180 - /* Allocate memory (2bit per block) */ 181 - bbm->bbt = kmalloc(len, GFP_KERNEL); 180 + /* Allocate memory (2bit per block) and clear the memory bad block table */ 181 + bbm->bbt = kzalloc(len, GFP_KERNEL); 182 182 if (!bbm->bbt) { 183 183 printk(KERN_ERR "onenand_scan_bbt: Out of memory\n"); 184 184 return -ENOMEM; 185 185 } 186 - /* Clear the memory bad block table */ 187 - memset(bbm->bbt, 0x00, len); 188 186 189 187 /* Set the bad block position */ 190 188 bbm->badblockpos = ONENAND_BADBLOCK_POS; ··· 228 230 struct onenand_chip *this = mtd->priv; 229 231 struct bbm_info *bbm; 230 232 231 - this->bbm = kmalloc(sizeof(struct bbm_info), GFP_KERNEL); 233 + this->bbm = kzalloc(sizeof(struct bbm_info), GFP_KERNEL); 232 234 if (!this->bbm) 233 235 return -ENOMEM; 234 236 235 237 bbm = this->bbm; 236 - 237 - memset(bbm, 0, sizeof(struct bbm_info)); 238 238 239 239 /* 1KB page has same configuration as 2KB page */ 240 240 if (!bbm->badblock_pattern)
+1 -3
drivers/mtd/redboot.c
··· 165 165 } 166 166 } 167 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 170 if (!parts) { 171 171 ret = -ENOMEM; 172 172 goto out; 173 173 } 174 - 175 - memset(parts, 0, sizeof(*parts)*nrparts + nulllen + namelen); 176 174 177 175 nullname = (char *)&parts[nrparts]; 178 176 #ifdef CONFIG_MTD_REDBOOT_PARTS_UNALLOCATED