aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/nand
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/mtd/nand')
-rw-r--r--drivers/mtd/nand/diskonchip.c3
-rw-r--r--drivers/mtd/nand/nand_bbt.c6
-rw-r--r--drivers/mtd/nand/nandsim.c4
3 files changed, 4 insertions, 9 deletions
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);