diff options
author | Jiri Kosina <jkosina@suse.cz> | 2011-07-11 08:15:48 -0400 |
---|---|---|
committer | Jiri Kosina <jkosina@suse.cz> | 2011-07-11 08:15:55 -0400 |
commit | b7e9c223be8ce335e30f2cf6ba588e6a4092275c (patch) | |
tree | 2d1e3b75606abc18df7ad65e51ac3f90cd68b38d /fs/romfs | |
parent | c172d82500a6cf3c32d1e650722a1055d72ce858 (diff) | |
parent | e3bbfa78bab125f58b831b5f7f45b5a305091d72 (diff) |
Merge branch 'master' into for-next
Sync with Linus' tree to be able to apply pending patches that
are based on newer code already present upstream.
Diffstat (limited to 'fs/romfs')
-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, | |||
27 | { | 27 | { |
28 | struct inode *inode = file->f_mapping->host; | 28 | struct inode *inode = file->f_mapping->host; |
29 | struct mtd_info *mtd = inode->i_sb->s_mtd; | 29 | struct mtd_info *mtd = inode->i_sb->s_mtd; |
30 | unsigned long isize, offset; | 30 | unsigned long isize, offset, maxpages, lpages; |
31 | 31 | ||
32 | if (!mtd) | 32 | if (!mtd) |
33 | goto cant_map_directly; | 33 | goto cant_map_directly; |
34 | 34 | ||
35 | /* the mapping mustn't extend beyond the EOF */ | ||
36 | lpages = (len + PAGE_SIZE - 1) >> PAGE_SHIFT; | ||
35 | isize = i_size_read(inode); | 37 | isize = i_size_read(inode); |
36 | offset = pgoff << PAGE_SHIFT; | 38 | offset = pgoff << PAGE_SHIFT; |
37 | if (offset > isize || len > isize || offset > isize - len) | 39 | |
40 | maxpages = (isize + PAGE_SIZE - 1) >> PAGE_SHIFT; | ||
41 | if ((pgoff >= maxpages) || (maxpages - pgoff < lpages)) | ||
38 | return (unsigned long) -EINVAL; | 42 | return (unsigned long) -EINVAL; |
39 | 43 | ||
40 | /* we need to call down to the MTD layer to do the actual mapping */ | 44 | /* we need to call down to the MTD layer to do the actual mapping */ |