diff options
Diffstat (limited to 'drivers/mtd/mtdchar.c')
-rw-r--r-- | drivers/mtd/mtdchar.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/drivers/mtd/mtdchar.c b/drivers/mtd/mtdchar.c index a0cee86464ca..5d3ac512ce16 100644 --- a/drivers/mtd/mtdchar.c +++ b/drivers/mtd/mtdchar.c | |||
@@ -481,6 +481,7 @@ static int mtd_ioctl(struct inode *inode, struct file *file, | |||
481 | { | 481 | { |
482 | struct mtd_oob_buf buf; | 482 | struct mtd_oob_buf buf; |
483 | struct mtd_oob_ops ops; | 483 | struct mtd_oob_ops ops; |
484 | uint32_t retlen; | ||
484 | 485 | ||
485 | if(!(file->f_mode & 2)) | 486 | if(!(file->f_mode & 2)) |
486 | return -EPERM; | 487 | return -EPERM; |
@@ -520,8 +521,11 @@ static int mtd_ioctl(struct inode *inode, struct file *file, | |||
520 | buf.start &= ~(mtd->oobsize - 1); | 521 | buf.start &= ~(mtd->oobsize - 1); |
521 | ret = mtd->write_oob(mtd, buf.start, &ops); | 522 | ret = mtd->write_oob(mtd, buf.start, &ops); |
522 | 523 | ||
523 | if (copy_to_user(argp + sizeof(uint32_t), &ops.oobretlen, | 524 | if (ops.oobretlen > 0xFFFFFFFFU) |
524 | sizeof(uint32_t))) | 525 | ret = -EOVERFLOW; |
526 | retlen = ops.oobretlen; | ||
527 | if (copy_to_user(&((struct mtd_oob_buf *)argp)->length, | ||
528 | &retlen, sizeof(buf.length))) | ||
525 | ret = -EFAULT; | 529 | ret = -EFAULT; |
526 | 530 | ||
527 | kfree(ops.oobbuf); | 531 | kfree(ops.oobbuf); |