aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mtd/mtdchar.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/mtd/mtdchar.c')
-rw-r--r--drivers/mtd/mtdchar.c24
1 files changed, 11 insertions, 13 deletions
diff --git a/drivers/mtd/mtdchar.c b/drivers/mtd/mtdchar.c
index aef9f4b687c9..d2f331876e4c 100644
--- a/drivers/mtd/mtdchar.c
+++ b/drivers/mtd/mtdchar.c
@@ -1,6 +1,4 @@
1/* 1/*
2 * $Id: mtdchar.c,v 1.76 2005/11/07 11:14:20 gleixner Exp $
3 *
4 * Character-device access to raw MTD devices. 2 * Character-device access to raw MTD devices.
5 * 3 *
6 */ 4 */
@@ -494,6 +492,7 @@ static int mtd_ioctl(struct inode *inode, struct file *file,
494 { 492 {
495 struct mtd_oob_buf buf; 493 struct mtd_oob_buf buf;
496 struct mtd_oob_ops ops; 494 struct mtd_oob_ops ops;
495 struct mtd_oob_buf __user *user_buf = argp;
497 uint32_t retlen; 496 uint32_t retlen;
498 497
499 if(!(file->f_mode & 2)) 498 if(!(file->f_mode & 2))
@@ -537,8 +536,7 @@ static int mtd_ioctl(struct inode *inode, struct file *file,
537 if (ops.oobretlen > 0xFFFFFFFFU) 536 if (ops.oobretlen > 0xFFFFFFFFU)
538 ret = -EOVERFLOW; 537 ret = -EOVERFLOW;
539 retlen = ops.oobretlen; 538 retlen = ops.oobretlen;
540 if (copy_to_user(&((struct mtd_oob_buf *)argp)->length, 539 if (copy_to_user(&user_buf->length, &retlen, sizeof(buf.length)))
541 &retlen, sizeof(buf.length)))
542 ret = -EFAULT; 540 ret = -EFAULT;
543 541
544 kfree(ops.oobbuf); 542 kfree(ops.oobbuf);
@@ -592,29 +590,29 @@ static int mtd_ioctl(struct inode *inode, struct file *file,
592 590
593 case MEMLOCK: 591 case MEMLOCK:
594 { 592 {
595 struct erase_info_user info; 593 struct erase_info_user einfo;
596 594
597 if (copy_from_user(&info, argp, sizeof(info))) 595 if (copy_from_user(&einfo, argp, sizeof(einfo)))
598 return -EFAULT; 596 return -EFAULT;
599 597
600 if (!mtd->lock) 598 if (!mtd->lock)
601 ret = -EOPNOTSUPP; 599 ret = -EOPNOTSUPP;
602 else 600 else
603 ret = mtd->lock(mtd, info.start, info.length); 601 ret = mtd->lock(mtd, einfo.start, einfo.length);
604 break; 602 break;
605 } 603 }
606 604
607 case MEMUNLOCK: 605 case MEMUNLOCK:
608 { 606 {
609 struct erase_info_user info; 607 struct erase_info_user einfo;
610 608
611 if (copy_from_user(&info, argp, sizeof(info))) 609 if (copy_from_user(&einfo, argp, sizeof(einfo)))
612 return -EFAULT; 610 return -EFAULT;
613 611
614 if (!mtd->unlock) 612 if (!mtd->unlock)
615 ret = -EOPNOTSUPP; 613 ret = -EOPNOTSUPP;
616 else 614 else
617 ret = mtd->unlock(mtd, info.start, info.length); 615 ret = mtd->unlock(mtd, einfo.start, einfo.length);
618 break; 616 break;
619 } 617 }
620 618
@@ -714,15 +712,15 @@ static int mtd_ioctl(struct inode *inode, struct file *file,
714 712
715 case OTPLOCK: 713 case OTPLOCK:
716 { 714 {
717 struct otp_info info; 715 struct otp_info oinfo;
718 716
719 if (mfi->mode != MTD_MODE_OTP_USER) 717 if (mfi->mode != MTD_MODE_OTP_USER)
720 return -EINVAL; 718 return -EINVAL;
721 if (copy_from_user(&info, argp, sizeof(info))) 719 if (copy_from_user(&oinfo, argp, sizeof(oinfo)))
722 return -EFAULT; 720 return -EFAULT;
723 if (!mtd->lock_user_prot_reg) 721 if (!mtd->lock_user_prot_reg)
724 return -EOPNOTSUPP; 722 return -EOPNOTSUPP;
725 ret = mtd->lock_user_prot_reg(mtd, info.start, info.length); 723 ret = mtd->lock_user_prot_reg(mtd, oinfo.start, oinfo.length);
726 break; 724 break;
727 } 725 }
728#endif 726#endif