aboutsummaryrefslogtreecommitdiffstats
path: root/mm/madvise.c
diff options
context:
space:
mode:
authorSuzuki <suzuki@in.ibm.com>2005-10-11 11:29:06 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2005-10-11 12:46:54 -0400
commit1bef40032992320dd25a266fc166bfb8fa3f2f59 (patch)
treee02d654b4db45b752e3201c3f6eec3f4c719b69f /mm/madvise.c
parent22c1ea44f0d33eda532883858b6cdabc5f265b66 (diff)
[PATCH] madvise: Avoid returning error code -EBADF for anonymous mappings
Revert this recent correctness change: Douglas Crosher <dcrosher@scieneer.com> reported that it broke an existing application, and that madvise() works without error on anonymous mappings on Solaris. This means that madvise() will remain non-standards-compliant: we should return -EBADF for all requests against non-file-backed vma's, but Linux only does this for MADV_WILLNEED requests. Signed-off-by: Suzuki K P <suzuki@in.ibm.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'mm/madvise.c')
-rw-r--r--mm/madvise.c11
1 files changed, 4 insertions, 7 deletions
diff --git a/mm/madvise.c b/mm/madvise.c
index 4454936f87d1..20e075d1c64c 100644
--- a/mm/madvise.c
+++ b/mm/madvise.c
@@ -83,6 +83,9 @@ static long madvise_willneed(struct vm_area_struct * vma,
83{ 83{
84 struct file *file = vma->vm_file; 84 struct file *file = vma->vm_file;
85 85
86 if (!file)
87 return -EBADF;
88
86 if (file->f_mapping->a_ops->get_xip_page) { 89 if (file->f_mapping->a_ops->get_xip_page) {
87 /* no bad return value, but ignore advice */ 90 /* no bad return value, but ignore advice */
88 return 0; 91 return 0;
@@ -141,11 +144,7 @@ static long
141madvise_vma(struct vm_area_struct *vma, struct vm_area_struct **prev, 144madvise_vma(struct vm_area_struct *vma, struct vm_area_struct **prev,
142 unsigned long start, unsigned long end, int behavior) 145 unsigned long start, unsigned long end, int behavior)
143{ 146{
144 struct file *filp = vma->vm_file; 147 long error;
145 long error = -EBADF;
146
147 if (!filp)
148 goto out;
149 148
150 switch (behavior) { 149 switch (behavior) {
151 case MADV_NORMAL: 150 case MADV_NORMAL:
@@ -166,8 +165,6 @@ madvise_vma(struct vm_area_struct *vma, struct vm_area_struct **prev,
166 error = -EINVAL; 165 error = -EINVAL;
167 break; 166 break;
168 } 167 }
169
170out:
171 return error; 168 return error;
172} 169}
173 170