diff options
author | Chris Metcalf <cmetcalf@tilera.com> | 2011-08-03 00:14:02 +0400 |
---|---|---|
committer | Chris Metcalf <cmetcalf@tilera.com> | 2011-08-03 00:14:02 +0400 |
commit | 3d071cd313643cf82b1ce1ce4fdf08d63ad53964 (patch) | |
tree | 874c1683f32f07614aa123f6ca5cf6c2bd443704 /fs/romfs/mmap-nommu.c | |
parent | cf8e98d15361f8c594da00a3f7a500787fc1a426 (diff) | |
parent | 02f8c6aee8df3cdc935e9bdd4f2d020306035dbe (diff) | |
download | linux-3d071cd313643cf82b1ce1ce4fdf08d63ad53964.tar.xz |
Merge tag 'v3.0' of git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6 into for-linus
Diffstat (limited to 'fs/romfs/mmap-nommu.c')
-rw-r--r-- | fs/romfs/mmap-nommu.c | 8 |
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 */ |