sys_remap_file_pages: fix ->vm_file accounting
authorOleg Nesterov <oleg@tv-sign.ru>
Tue, 5 Feb 2008 06:27:18 +0000 (22:27 -0800)
committerLinus Torvalds <torvalds@woody.linux-foundation.org>
Tue, 5 Feb 2008 17:44:07 +0000 (09:44 -0800)
Fix ->vm_file accounting, mmap_region() may do do_munmap().

Signed-off-by: Oleg Nesterov <oleg@tv-sign.ru>
Signed-off-by: Miklos Szeredi <mszeredi@suse.cz>
Cc: <stable@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
mm/fremap.c

index 14bd3bf7826edcecd2f61e6465b61078a84b2340..69a37c2bdf815ce5d7d14f90cca4c1185b65dff7 100644 (file)
@@ -190,10 +190,13 @@ asmlinkage long sys_remap_file_pages(unsigned long start, unsigned long size,
                 */
                if (mapping_cap_account_dirty(mapping)) {
                        unsigned long addr;
+                       struct file *file = vma->vm_file;
 
                        flags &= MAP_NONBLOCK;
-                       addr = mmap_region(vma->vm_file, start, size,
+                       get_file(file);
+                       addr = mmap_region(file, start, size,
                                        flags, vma->vm_flags, pgoff, 1);
+                       fput(file);
                        if (IS_ERR_VALUE(addr)) {
                                err = addr;
                        } else {