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

mtd: nand: ams-delta: fix overwritten mtd_info->owner in initialization

In initialization routine, mtd_info->owner is overwritten by memset()
just after being initialized. This can be fixed by moving memset() calls
to just before setting mtd_info->owner. But the memory region is allocated
by kmalloc, so we can fix it by using kzalloc instead of kmalloc.

Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Cc: Jonathan McDowell <noodles@earth.li>
Cc: David Woodhouse <dwmw2@infradead.org>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>

authored by

Akinobu Mita and committed by
Brian Norris
526789fc 45c6a0ca

+1 -5
+1 -5
drivers/mtd/nand/ams-delta.c
··· 183 183 return -ENXIO; 184 184 185 185 /* Allocate memory for MTD device structure and private data */ 186 - ams_delta_mtd = kmalloc(sizeof(struct mtd_info) + 186 + ams_delta_mtd = kzalloc(sizeof(struct mtd_info) + 187 187 sizeof(struct nand_chip), GFP_KERNEL); 188 188 if (!ams_delta_mtd) { 189 189 printk (KERN_WARNING "Unable to allocate E3 NAND MTD device structure.\n"); ··· 195 195 196 196 /* Get pointer to private data */ 197 197 this = (struct nand_chip *) (&ams_delta_mtd[1]); 198 - 199 - /* Initialize structures */ 200 - memset(ams_delta_mtd, 0, sizeof(struct mtd_info)); 201 - memset(this, 0, sizeof(struct nand_chip)); 202 198 203 199 /* Link the private data with the MTD structure */ 204 200 ams_delta_mtd->priv = this;