aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/romfs/mmap-nommu.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/fs/romfs/mmap-nommu.c b/fs/romfs/mmap-nommu.c
index e1a7779dd3cb..f373bde8f545 100644
--- a/fs/romfs/mmap-nommu.c
+++ b/fs/romfs/mmap-nommu.c
@@ -49,8 +49,11 @@ static unsigned long romfs_get_unmapped_area(struct file *file,
49 return (unsigned long) -EINVAL; 49 return (unsigned long) -EINVAL;
50 50
51 offset += ROMFS_I(inode)->i_dataoffset; 51 offset += ROMFS_I(inode)->i_dataoffset;
52 if (offset > mtd->size - len) 52 if (offset >= mtd->size)
53 return (unsigned long) -EINVAL; 53 return (unsigned long) -EINVAL;
54 /* the mapping mustn't extend beyond the EOF */
55 if ((offset + len) > mtd->size)
56 len = mtd->size - offset;
54 57
55 ret = mtd_get_unmapped_area(mtd, len, offset, flags); 58 ret = mtd_get_unmapped_area(mtd, len, offset, flags);
56 if (ret == -EOPNOTSUPP) 59 if (ret == -EOPNOTSUPP)