diff options
Diffstat (limited to 'drivers/mtd/mtdchar.c')
-rw-r--r-- | drivers/mtd/mtdchar.c | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/drivers/mtd/mtdchar.c b/drivers/mtd/mtdchar.c index 000d65ea55a4..91c8013cf0d9 100644 --- a/drivers/mtd/mtdchar.c +++ b/drivers/mtd/mtdchar.c | |||
@@ -404,14 +404,9 @@ static int mtd_do_writeoob(struct file *file, struct mtd_info *mtd, | |||
404 | if (ops.ooboffs && ops.ooblen > (mtd->oobsize - ops.ooboffs)) | 404 | if (ops.ooboffs && ops.ooblen > (mtd->oobsize - ops.ooboffs)) |
405 | return -EINVAL; | 405 | return -EINVAL; |
406 | 406 | ||
407 | ops.oobbuf = kmalloc(length, GFP_KERNEL); | 407 | ops.oobbuf = memdup_user(ptr, length); |
408 | if (!ops.oobbuf) | 408 | if (IS_ERR(ops.oobbuf)) |
409 | return -ENOMEM; | 409 | return PTR_ERR(ops.oobbuf); |
410 | |||
411 | if (copy_from_user(ops.oobbuf, ptr, length)) { | ||
412 | kfree(ops.oobbuf); | ||
413 | return -EFAULT; | ||
414 | } | ||
415 | 410 | ||
416 | start &= ~((uint64_t)mtd->oobsize - 1); | 411 | start &= ~((uint64_t)mtd->oobsize - 1); |
417 | ret = mtd->write_oob(mtd, start, &ops); | 412 | ret = mtd->write_oob(mtd, start, &ops); |