summaryrefslogtreecommitdiff
path: root/fs/romfs/mmap-nommu.c
diff options
context:
space:
mode:
authorArnd Bergmann <arnd@arndb.de>2011-07-15 23:56:37 +0400
committerArnd Bergmann <arnd@arndb.de>2011-07-15 23:56:37 +0400
commit62778396020a29d742abf980c1e83f3df4b5426e (patch)
tree08dc01019a1afe6ed16ab79c627ecd81caea52e0 /fs/romfs/mmap-nommu.c
parent58f45e3c6f4fd2b9b9d7d43af71409a79a4b4cf6 (diff)
parentd3144df5bd8eb1c8137cc92989e2e6bc9f2e5a27 (diff)
downloadlinux-62778396020a29d742abf980c1e83f3df4b5426e.tar.xz
Merge branch 'fixes-for-arnd' of git://git.pengutronix.de/git/imx/linux-2.6 into imx/fixes
Diffstat (limited to 'fs/romfs/mmap-nommu.c')
-rw-r--r--fs/romfs/mmap-nommu.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/fs/romfs/mmap-nommu.c b/fs/romfs/mmap-nommu.c
index f0511e816967..eed99428f104 100644
--- a/fs/romfs/mmap-nommu.c
+++ b/fs/romfs/mmap-nommu.c
@@ -27,14 +27,18 @@ static unsigned long romfs_get_unmapped_area(struct file *file,
{
struct inode *inode = file->f_mapping->host;
struct mtd_info *mtd = inode->i_sb->s_mtd;
- unsigned long isize, offset;
+ unsigned long isize, offset, maxpages, lpages;
if (!mtd)
goto cant_map_directly;
+ /* the mapping mustn't extend beyond the EOF */
+ lpages = (len + PAGE_SIZE - 1) >> PAGE_SHIFT;
isize = i_size_read(inode);
offset = pgoff << PAGE_SHIFT;
- if (offset > isize || len > isize || offset > isize - len)
+
+ maxpages = (isize + PAGE_SIZE - 1) >> PAGE_SHIFT;
+ if ((pgoff >= maxpages) || (maxpages - pgoff < lpages))
return (unsigned long) -EINVAL;
/* we need to call down to the MTD layer to do the actual mapping */