[MTD] CORE mtdchar.c: fix off-by-one error in lseek()

Linux-MTD Mailing List linux-mtd at lists.infradead.org
Tue Jun 27 18:59:01 EDT 2006


Commit:     1887f517e3cdf5f1e9c0e4daaa864450415a8f61
Parent:     0e4ced59de7c0c23588d2b3f6d302592545cd12e
commit 1887f517e3cdf5f1e9c0e4daaa864450415a8f61
Author:     Herbert Valerio Riedel <hvr at gnu.org>
AuthorDate: Sat Jun 24 00:03:36 2006 +0200
Commit:     David Woodhouse <dwmw2 at infradead.org>
CommitDate: Tue Jun 27 23:22:07 2006 +0100

    [MTD] CORE mtdchar.c: fix off-by-one error in lseek()
    
    Allow lseek(mtdchar_fd, 0, SEEK_END) to succeed, which currently fails
    with EINVAL.
    
    lseek(fd, 0, SEEK_END) should result into the same fileposition as
    lseek(fd, 0, SEEK_SET) + read(fd, buf, length(fd))
    
    Furthermore, lseek(fd, 0, SEEK_CUR) should return the current file position,
    which in case of an encountered EOF should not result in EINVAL
    
    Signed-off-by: Herbert Valerio Riedel <hvr at gnu.org>
    Signed-off-by: Thomas Gleixner <tglx at linutronix.de>
    Signed-off-by: David Woodhouse <dwmw2 at infradead.org>
---
 drivers/mtd/mtdchar.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/mtd/mtdchar.c b/drivers/mtd/mtdchar.c
index aa18d45..9a4b59d 100644
--- a/drivers/mtd/mtdchar.c
+++ b/drivers/mtd/mtdchar.c
@@ -78,7 +78,7 @@ static loff_t mtd_lseek (struct file *fi
 		return -EINVAL;
 	}
 
-	if (offset >= 0 && offset < mtd->size)
+	if (offset >= 0 && offset <= mtd->size)
 		return file->f_pos = offset;
 
 	return -EINVAL;



More information about the linux-mtd-cvs mailing list