Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

frv: fix mmap2 error handling

Fix the error handling in sys_mmap2(). Currently, if the pgoff check
fails, fput() might have to be called (which it isn't), so do the pgoff
check first, before fget() is called.

Signed-off-by: David Howells <dhowells@redhat.com>
Reported-by: Julia Lawall <julia@diku.dk>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

David Howells and committed by
Linus Torvalds
4280e312 a8005992

+9 -10
+9 -10
arch/frv/kernel/sys_frv.c
··· 35 35 int error = -EBADF; 36 36 struct file * file = NULL; 37 37 38 + /* As with sparc32, make sure the shift for mmap2 is constant 39 + (12), no matter what PAGE_SIZE we have.... */ 40 + 41 + /* But unlike sparc32, don't just silently break if we're 42 + trying to map something we can't */ 43 + if (pgoff & ((1 << (PAGE_SHIFT - 12)) - 1)) 44 + return -EINVAL; 45 + pgoff >>= PAGE_SHIFT - 12; 46 + 38 47 flags &= ~(MAP_EXECUTABLE | MAP_DENYWRITE); 39 48 if (!(flags & MAP_ANONYMOUS)) { 40 49 file = fget(fd); 41 50 if (!file) 42 51 goto out; 43 52 } 44 - 45 - /* As with sparc32, make sure the shift for mmap2 is constant 46 - (12), no matter what PAGE_SIZE we have.... */ 47 - 48 - /* But unlike sparc32, don't just silently break if we're 49 - trying to map something we can't */ 50 - if (pgoff & ((1<<(PAGE_SHIFT-12))-1)) 51 - return -EINVAL; 52 - 53 - pgoff >>= (PAGE_SHIFT - 12); 54 53 55 54 down_write(&current->mm->mmap_sem); 56 55 error = do_mmap_pgoff(file, addr, len, prot, flags, pgoff);