Commit d7c43720 authored by David Howells's avatar David Howells Committed by Linus Torvalds

[PATCH] NOMMU: Improved handling of get_unmapped_area() errors

The attached patch does two things:

 (1) We no longer check the return value of file->f_op->get_unmapped_area()
     unless we actually called it. We know addr is zero otherwise because
     we'd've given an error earlier if it wasn't.

 (2) If -ENOSYS was returned by that operation, then we assume we actually
     called a driver (such as the framebuffer driver) that might want to
     invoke the operation in a lower level driver (such as matroxfb) if one
     exists, and that it found that one didn't.

     We translate the -ENOSYS error into -ENODEV - the error we would have
     given if the operation was not supplied in the file ops.

     Doing this permits us an opportunity for arch_get_unmapped_area() or
     something else to be called if we want that to happen, particularly in
     the MMU case.
Signed-Off-By: default avatarDavid Howells <dhowells@redhat.com>
Signed-Off-By: default avatarLinus Torvalds <torvalds@osdl.org>
parent ca323f21
......@@ -567,12 +567,14 @@ unsigned long do_mmap_pgoff(struct file *file,
* that it represents a valid section of the address space
* - this is the hook for quasi-memory character devices
*/
if (file && file->f_op->get_unmapped_area)
if (file && file->f_op->get_unmapped_area) {
addr = file->f_op->get_unmapped_area(file, addr, len, pgoff, flags);
if (IS_ERR((void *) addr)) {
ret = addr;
goto error;
if (IS_ERR((void *) addr)) {
ret = addr;
if (ret == (unsigned long) -ENOSYS)
ret = (unsigned long) -ENODEV;
goto error;
}
}
/* we're going to need a VMA struct as well */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment