* [PATCH] mtd: nand: ams-delta: fix overwritten mtd_info->owner in initialization
@ 2015-01-11 13:07 Akinobu Mita
2015-01-16 3:33 ` Brian Norris
0 siblings, 1 reply; 2+ messages in thread
From: Akinobu Mita @ 2015-01-11 13:07 UTC (permalink / raw)
To: linux-mtd; +Cc: Brian Norris, Jonathan McDowell, David Woodhouse, Akinobu Mita
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>
Cc: Brian Norris <computersforpeace@gmail.com>
Cc: linux-mtd@lists.infradead.org
---
drivers/mtd/nand/ams-delta.c | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/drivers/mtd/nand/ams-delta.c b/drivers/mtd/nand/ams-delta.c
index f1d555c..842f8fe 100644
--- a/drivers/mtd/nand/ams-delta.c
+++ b/drivers/mtd/nand/ams-delta.c
@@ -183,7 +183,7 @@ static int ams_delta_init(struct platform_device *pdev)
return -ENXIO;
/* Allocate memory for MTD device structure and private data */
- ams_delta_mtd = kmalloc(sizeof(struct mtd_info) +
+ ams_delta_mtd = kzalloc(sizeof(struct mtd_info) +
sizeof(struct nand_chip), GFP_KERNEL);
if (!ams_delta_mtd) {
printk (KERN_WARNING "Unable to allocate E3 NAND MTD device structure.\n");
@@ -196,10 +196,6 @@ static int ams_delta_init(struct platform_device *pdev)
/* Get pointer to private data */
this = (struct nand_chip *) (&ams_delta_mtd[1]);
- /* Initialize structures */
- memset(ams_delta_mtd, 0, sizeof(struct mtd_info));
- memset(this, 0, sizeof(struct nand_chip));
-
/* Link the private data with the MTD structure */
ams_delta_mtd->priv = this;
--
1.9.1
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] mtd: nand: ams-delta: fix overwritten mtd_info->owner in initialization
2015-01-11 13:07 [PATCH] mtd: nand: ams-delta: fix overwritten mtd_info->owner in initialization Akinobu Mita
@ 2015-01-16 3:33 ` Brian Norris
0 siblings, 0 replies; 2+ messages in thread
From: Brian Norris @ 2015-01-16 3:33 UTC (permalink / raw)
To: Akinobu Mita; +Cc: David Woodhouse, Jonathan McDowell, linux-mtd
On Sun, Jan 11, 2015 at 10:07:20PM +0900, Akinobu Mita wrote:
> 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>
> Cc: Brian Norris <computersforpeace@gmail.com>
> Cc: linux-mtd@lists.infradead.org
Pushed to l2-mtd.git. Thanks!
Brian
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-01-16 3:34 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-01-11 13:07 [PATCH] mtd: nand: ams-delta: fix overwritten mtd_info->owner in initialization Akinobu Mita
2015-01-16 3:33 ` Brian Norris
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox