aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Scidmore <dscidmore@xes-inc.com>2007-12-11 18:44:30 -0500
committerDavid Woodhouse <dwmw2@infradead.org>2008-01-08 02:46:12 -0500
commite9d8d48253c50106d85b288939e5227083360863 (patch)
tree4a0602108bccdc31ebde7306fa1b13734531349d
parent4b3cc340614e552c476bec29d984c5a363b26494 (diff)
[MTD] mtdchar.c: ioctl always returns 0 as size written for ppc64
"include/linux/mtd/mtd.h" declares "mtd_oob_ops.retlen" as size_t, which is 64 bits on targets with a 64 bit addressing. The MEMWRITEOOB ioctl calls copy_to_user() to write it back to "mtd_oob_buf.length", which is declared in "include/linux/mtd-abi.h" as uint32_t. Since powerpc is a big endian architecture, this only copies the upper 32 bits of the address, which is always 0. Signed-off-by: David Scidmore <dscidmore@xes-inc.com> Signed-off-by: David Woodhouse <dwmw2@infradead.org>
-rw-r--r--drivers/mtd/mtdchar.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/drivers/mtd/mtdchar.c b/drivers/mtd/mtdchar.c
index 22ed96c4b7bd..b42553cd9af5 100644
--- a/drivers/mtd/mtdchar.c
+++ b/drivers/mtd/mtdchar.c
@@ -483,6 +483,7 @@ static int mtd_ioctl(struct inode *inode, struct file *file,
483 { 483 {
484 struct mtd_oob_buf buf; 484 struct mtd_oob_buf buf;
485 struct mtd_oob_ops ops; 485 struct mtd_oob_ops ops;
486 uint32_t retlen;
486 487
487 if(!(file->f_mode & 2)) 488 if(!(file->f_mode & 2))
488 return -EPERM; 489 return -EPERM;
@@ -522,8 +523,11 @@ static int mtd_ioctl(struct inode *inode, struct file *file,
522 buf.start &= ~(mtd->oobsize - 1); 523 buf.start &= ~(mtd->oobsize - 1);
523 ret = mtd->write_oob(mtd, buf.start, &ops); 524 ret = mtd->write_oob(mtd, buf.start, &ops);
524 525
525 if (copy_to_user(argp + sizeof(uint32_t), &ops.oobretlen, 526 if (ops.oobretlen > 0xFFFFFFFFU)
526 sizeof(uint32_t))) 527 ret = -EOVERFLOW;
528 retlen = ops.oobretlen;
529 if (copy_to_user(&((struct mtd_oob_buf *)argp)->length,
530 &retlen, sizeof(buf.length)))
527 ret = -EFAULT; 531 ret = -EFAULT;
528 532
529 kfree(ops.oobbuf); 533 kfree(ops.oobbuf);