Fixed page fault handler.
authorFlorian Pose <fp@igh-essen.com>
Tue, 21 Oct 2008 09:26:19 +0000
changeset 1284 283aab089eb5
parent 1283 e539c765f6a6
child 1285 f16b38b8b696
Fixed page fault handler.
master/cdev.c
--- a/master/cdev.c	Mon Oct 20 15:37:51 2008 +0000
+++ b/master/cdev.c	Tue Oct 21 09:26:19 2008 +0000
@@ -2612,21 +2612,24 @@
         struct vm_fault *vmf /**< Fault data. */
         )
 {
+    unsigned long offset = vmf->pgoff << PAGE_SHIFT;
+    ec_cdev_priv_t *priv = (ec_cdev_priv_t *) vma->vm_private_data;
     struct page *page;
-    ec_cdev_priv_t *priv = (ec_cdev_priv_t *) vma->vm_private_data;
-
-    if (vmf->pgoff >= priv->process_data_size)
+
+    if (offset >= priv->process_data_size)
         return VM_FAULT_SIGBUS;
 
-    page = vmalloc_to_page(priv->process_data + vmf->pgoff);
-
-    if (priv->cdev->master->debug_level)
-        EC_DBG("Vma fault, address = %p, offset = %lu, page = %p\n",
-                vmf->virtual_address, vmf->pgoff, page);
+    page = vmalloc_to_page(priv->process_data + offset);
+    if (!page)
+        return VM_FAULT_SIGBUS;
 
     get_page(page);
     vmf->page = page;
-    vmf->flags = 0;
+
+    if (priv->cdev->master->debug_level)
+        EC_DBG("Vma fault, virtual_address = %p, offset = %lu, page = %p\n",
+                vmf->virtual_address, offset, page);
+
     return 0;
 }