Allow the VM fault handler to be NULL in the LinuxKPI when handling a

memory map request. When the VM fault handler is NULL a return code of
VM_PAGER_BAD is returned from the character device's pager populate
handler. This fixes compatibility with Linux.

MFC after:	1 week
Sponsored by:	Mellanox Technologies
This commit is contained in:
Hans Petter Selasky 2017-06-21 14:38:52 +00:00
parent 3f6a9d3760
commit cde3f930bc

View File

@ -497,7 +497,7 @@ linux_cdev_pager_populate(vm_object_t vm_obj, vm_pindex_t pidx, int fault_type,
VM_OBJECT_WUNLOCK(vm_obj);
down_write(&vmap->vm_mm->mmap_sem);
if (unlikely(vmap->vm_ops == NULL)) {
if (unlikely(vmap->vm_ops == NULL || vmap->vm_ops->fault == NULL)) {
err = VM_FAULT_SIGBUS;
} else {
vmap->vm_pfn_count = 0;
@ -1173,8 +1173,7 @@ linux_dev_mmap_single(struct cdev *dev, vm_ooffset_t *offset,
if (vmap->vm_ops != NULL) {
void *vm_private_data;
if (vmap->vm_ops->fault == NULL ||
vmap->vm_ops->open == NULL ||
if (vmap->vm_ops->open == NULL ||
vmap->vm_ops->close == NULL ||
vmap->vm_private_data == NULL) {
linux_cdev_handle_free(vmap);