aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/mtd/mtdchar.c9
-rw-r--r--include/linux/mtd/mtd.h4
2 files changed, 6 insertions, 7 deletions
diff --git a/drivers/mtd/mtdchar.c b/drivers/mtd/mtdchar.c
index 55f0961103a7..287ff0d35848 100644
--- a/drivers/mtd/mtdchar.c
+++ b/drivers/mtd/mtdchar.c
@@ -452,13 +452,8 @@ static int mtdchar_readoob(struct file *file, struct mtd_info *mtd,
452 if (length > 4096) 452 if (length > 4096)
453 return -EINVAL; 453 return -EINVAL;
454 454
455 if (!mtd->read_oob) 455 if (!access_ok(VERIFY_WRITE, ptr, length))
456 ret = -EOPNOTSUPP; 456 return -EFAULT;
457 else
458 ret = access_ok(VERIFY_WRITE, ptr,
459 length) ? 0 : -EFAULT;
460 if (ret)
461 return ret;
462 457
463 ops.ooblen = length; 458 ops.ooblen = length;
464 ops.ooboffs = start & (mtd->writesize - 1); 459 ops.ooboffs = start & (mtd->writesize - 1);
diff --git a/include/linux/mtd/mtd.h b/include/linux/mtd/mtd.h
index b72964049cdc..721a63ffeb96 100644
--- a/include/linux/mtd/mtd.h
+++ b/include/linux/mtd/mtd.h
@@ -320,6 +320,8 @@ static inline int mtd_read_oob(struct mtd_info *mtd, loff_t from,
320 struct mtd_oob_ops *ops) 320 struct mtd_oob_ops *ops)
321{ 321{
322 ops->retlen = ops->oobretlen = 0; 322 ops->retlen = ops->oobretlen = 0;
323 if (!mtd->read_oob)
324 return -EOPNOTSUPP;
323 return mtd->read_oob(mtd, from, ops); 325 return mtd->read_oob(mtd, from, ops);
324} 326}
325 327
@@ -327,6 +329,8 @@ static inline int mtd_write_oob(struct mtd_info *mtd, loff_t to,
327 struct mtd_oob_ops *ops) 329 struct mtd_oob_ops *ops)
328{ 330{
329 ops->retlen = ops->oobretlen = 0; 331 ops->retlen = ops->oobretlen = 0;
332 if (!mtd->write_oob)
333 return -EOPNOTSUPP;
330 return mtd->write_oob(mtd, to, ops); 334 return mtd->write_oob(mtd, to, ops);
331} 335}
332 336