patch-2.3.51 linux/mm/mmap.c

Next file: linux/net/Config.in
Previous file: linux/mm/memory.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.3.50/linux/mm/mmap.c linux/mm/mmap.c
@@ -305,14 +305,14 @@
 			atomic_dec(&file->f_dentry->d_inode->i_writecount);
 			correct_wcount = 1;
 		}
+		vma->vm_file = file;
+		get_file(file);
 		error = file->f_op->mmap(file, vma);
 		/* Fix up the count if necessary, then check for an error */
 		if (correct_wcount)
 			atomic_inc(&file->f_dentry->d_inode->i_writecount);
 		if (error)
 			goto unmap_and_free_vma;
-		vma->vm_file = file;
-		get_file(file);
 	}
 
 	/*
@@ -334,6 +334,8 @@
 	return addr;
 
 unmap_and_free_vma:
+	vma->vm_file = NULL;
+	fput(file);
 	/* Undo any partial mapping done by a device driver. */
 	flush_cache_range(mm, vma->vm_start, vma->vm_end);
 	zap_page_range(mm, vma->vm_start, vma->vm_end - vma->vm_start);

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)