From 1887f517e3cdf5f1e9c0e4daaa864450415a8f61 Mon Sep 17 00:00:00 2001 From: Herbert Valerio Riedel Date: Sat, 24 Jun 2006 00:03:36 +0200 Subject: [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 Signed-off-by: Thomas Gleixner Signed-off-by: David Woodhouse --- drivers/mtd/mtdchar.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/mtd/mtdchar.c') diff --git a/drivers/mtd/mtdchar.c b/drivers/mtd/mtdchar.c index aa18d45b264..9a4b59d9252 100644 --- a/drivers/mtd/mtdchar.c +++ b/drivers/mtd/mtdchar.c @@ -78,7 +78,7 @@ static loff_t mtd_lseek (struct file *file, loff_t offset, int orig) return -EINVAL; } - if (offset >= 0 && offset < mtd->size) + if (offset >= 0 && offset <= mtd->size) return file->f_pos = offset; return -EINVAL; -- cgit v1.2.3