summaryrefslogtreecommitdiffstats
path: root/drivers/mtd/mtdchar.c
diff options
context:
space:
mode:
authorTodd Poynor <tpoynor@mvista.com>2005-08-04 02:05:51 +0100
committerThomas Gleixner <tglx@mtd.linutronix.de>2005-08-04 12:52:40 +0200
commit8b491d750885ebe8e7d385ce4186c85957d67123 (patch)
tree18c7eb52bfc8821eaf08430fdaa5ce70078f2200 /drivers/mtd/mtdchar.c
parent1da2c9a638f8af7be3daf1fa8dbd087b3284d16e (diff)
downloadkernel-crypto-8b491d750885ebe8e7d385ce4186c85957d67123.tar.gz
kernel-crypto-8b491d750885ebe8e7d385ce4186c85957d67123.tar.xz
kernel-crypto-8b491d750885ebe8e7d385ce4186c85957d67123.zip
[MTD] mtdchar: Return EINVAL for bad seeks instead of fixing up to valid byte
mtdchar return -EINVAL for seek prior to offset 0 or to beyond the last byte in the device/partition, similar to various other seek methods, instead of fixing up to first or last byte. Signed-off-by: Todd Poynor <tpoynor@mvista.com> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'drivers/mtd/mtdchar.c')
-rw-r--r--drivers/mtd/mtdchar.c15
1 files changed, 6 insertions, 9 deletions
diff --git a/drivers/mtd/mtdchar.c b/drivers/mtd/mtdchar.c
index 1ed602a0f24..4b3c6263e7f 100644
--- a/drivers/mtd/mtdchar.c
+++ b/drivers/mtd/mtdchar.c
@@ -1,5 +1,5 @@
/*
- * $Id: mtdchar.c,v 1.73 2005/07/04 17:36:41 gleixner Exp $
+ * $Id: mtdchar.c,v 1.74 2005/08/04 01:05:48 tpoynor Exp $
*
* Character-device access to raw MTD devices.
*
@@ -69,26 +69,23 @@ static loff_t mtd_lseek (struct file *file, loff_t offset, int orig)
switch (orig) {
case 0:
/* SEEK_SET */
- file->f_pos = offset;
break;
case 1:
/* SEEK_CUR */
- file->f_pos += offset;
+ offset += file->f_pos;
break;
case 2:
/* SEEK_END */
- file->f_pos =mtd->size + offset;
+ offset += mtd->size;
break;
default:
return -EINVAL;
}
- if (file->f_pos < 0)
- file->f_pos = 0;
- else if (file->f_pos >= mtd->size)
- file->f_pos = mtd->size - 1;
+ if (offset >= 0 && offset < mtd->size)
+ return file->f_pos = offset;
- return file->f_pos;
+ return -EINVAL;
}