From cde3f930bce271d70eb78d8aeef20aabbbb9ba0e Mon Sep 17 00:00:00 2001 From: Hans Petter Selasky Date: Wed, 21 Jun 2017 14:38:52 +0000 Subject: [PATCH] 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 --- sys/compat/linuxkpi/common/src/linux_compat.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/sys/compat/linuxkpi/common/src/linux_compat.c b/sys/compat/linuxkpi/common/src/linux_compat.c index 8df5de6329b6..d476a91b8945 100644 --- a/sys/compat/linuxkpi/common/src/linux_compat.c +++ b/sys/compat/linuxkpi/common/src/linux_compat.c @@ -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);