aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/mtd')
-rw-r--r--drivers/mtd/mtdchar.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/drivers/mtd/mtdchar.c b/drivers/mtd/mtdchar.c
index 22ed96c4b7bd..b42553cd9af5 100644
--- a/drivers/mtd/mtdchar.c
+++ b/drivers/mtd/mtdchar.c
@@ -483,6 +483,7 @@ static int mtd_ioctl(struct inode *inode, struct file *file,
483 { 483 {
484 struct mtd_oob_buf buf; 484 struct mtd_oob_buf buf;
485 struct mtd_oob_ops ops; 485 struct mtd_oob_ops ops;
486 uint32_t retlen;
486 487
487 if(!(file->f_mode & 2)) 488 if(!(file->f_mode & 2))
488 return -EPERM; 489 return -EPERM;
@@ -522,8 +523,11 @@ static int mtd_ioctl(struct inode *inode, struct file *file,
522 buf.start &= ~(mtd->oobsize - 1); 523 buf.start &= ~(mtd->oobsize - 1);
523 ret = mtd->write_oob(mtd, buf.start, &ops); 524 ret = mtd->write_oob(mtd, buf.start, &ops);
524 525
525 if (copy_to_user(argp + sizeof(uint32_t), &ops.oobretlen, 526 if (ops.oobretlen > 0xFFFFFFFFU)
526 sizeof(uint32_t))) 527 ret = -EOVERFLOW;
528 retlen = ops.oobretlen;
529 if (copy_to_user(&((struct mtd_oob_buf *)argp)->length,
530 &retlen, sizeof(buf.length)))
527 ret = -EFAULT; 531 ret = -EFAULT;
528 532
529 kfree(ops.oobbuf); 533 kfree(ops.oobbuf);