Skip to content

Commit

Permalink
[MTD] CORE mtdchar.c: fix off-by-one error in lseek()
Browse files Browse the repository at this point in the history
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@gnu.org>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: David Woodhouse <dwmw2@infradead.org>
  • Loading branch information
Herbert Valerio Riedel authored and David Woodhouse committed Jun 27, 2006
1 parent 0e4ced5 commit 1887f51
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/mtd/mtdchar.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 1887f51

Please sign in to comment.