aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/mtd/mtdchar.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/drivers/mtd/mtdchar.c b/drivers/mtd/mtdchar.c
index d2f331876e4c..e00d424e6575 100644
--- a/drivers/mtd/mtdchar.c
+++ b/drivers/mtd/mtdchar.c
@@ -410,16 +410,20 @@ static int mtd_ioctl(struct inode *inode, struct file *file,
410 410
411 case MEMGETREGIONINFO: 411 case MEMGETREGIONINFO:
412 { 412 {
413 struct region_info_user ur; 413 uint32_t ur_idx;
414 struct mtd_erase_region_info *kr;
415 struct region_info_user *ur = (struct region_info_user *) argp;
414 416
415 if (copy_from_user(&ur, argp, sizeof(struct region_info_user))) 417 if (get_user(ur_idx, &(ur->regionindex)))
416 return -EFAULT; 418 return -EFAULT;
417 419
418 if (ur.regionindex >= mtd->numeraseregions) 420 kr = &(mtd->eraseregions[ur_idx]);
419 return -EINVAL; 421
420 if (copy_to_user(argp, &(mtd->eraseregions[ur.regionindex]), 422 if (put_user(kr->offset, &(ur->offset))
421 sizeof(struct mtd_erase_region_info))) 423 || put_user(kr->erasesize, &(ur->erasesize))
424 || put_user(kr->numblocks, &(ur->numblocks)))
422 return -EFAULT; 425 return -EFAULT;
426
423 break; 427 break;
424 } 428 }
425 429