[PATCH 1/1] MTD: Fix MTD_MODE_RAW write fail
Frank Li
Frank.Li at freescale.com
Mon Oct 25 22:54:20 EDT 2010
mtdchar have not initilized all field of struct mtd_oob_ops
in mtd_write when mode is MTD_MODE_RAW.
function nand_do_write_ops
if (ops->ooboffs && (ops->ooboffs + ops->ooblen > oobmaxlen))
return -EINVAL;
ooboffs is not initilized at mtd_write.
So random data cause nand_do_write_ops return fail.
Signed-off-by: Frank Li <Frank.Li at freescale.com>
---
drivers/mtd/mtdchar.c | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/drivers/mtd/mtdchar.c b/drivers/mtd/mtdchar.c
index b7ed09c..58839fa 100644
--- a/drivers/mtd/mtdchar.c
+++ b/drivers/mtd/mtdchar.c
@@ -319,6 +319,7 @@ static ssize_t mtd_write(struct file *file, const char __user *buf, size_t count
case MTD_MODE_RAW:
{
struct mtd_oob_ops ops;
+ memset(&ops, 0, sizeof(struct mtd_oob_ops));
ops.mode = MTD_OOB_RAW;
ops.datbuf = kbuf;
--
1.7.1
More information about the linux-mtd
mailing list