staging/rdma/hfi1: Wrong cast breaks desired pointer arithmetic
authorMitko Haralanov <mitko.haralanov@intel.com>
Mon, 26 Oct 2015 14:28:39 +0000 (10:28 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 27 Oct 2015 08:20:41 +0000 (17:20 +0900)
The address being mapped into a process's memory for notification events was
improperly calculated due to cast that was happening too early. dd->events is a
pointer and should have been casted to unsigned long after the pointer
arithmetic was done, not before.

As a result, processes were looking at the wrong place and not seeing their
notification events.

Signed-off-by: Mitko Haralanov <mitko.haralanov@intel.com>
Signed-off-by: Ira Weiny <ira.weiny@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/rdma/hfi1/file_ops.c

index 955f80dfecf618996fe2755fb1ffe6182ea1c832..aae9826ec62bea8e86a6f1f7c4408ff574d72204 100644 (file)
@@ -607,9 +607,9 @@ static int hfi1_file_mmap(struct file *fp, struct vm_area_struct *vma)
                 * Use the page where this context's flags are. User level
                 * knows where it's own bitmap is within the page.
                 */
-               memaddr = ((unsigned long)dd->events +
-                          ((uctxt->ctxt - dd->first_user_ctxt) *
-                           HFI1_MAX_SHARED_CTXTS)) & PAGE_MASK;
+               memaddr = (unsigned long)(dd->events +
+                                         ((uctxt->ctxt - dd->first_user_ctxt) *
+                                          HFI1_MAX_SHARED_CTXTS)) & PAGE_MASK;
                memlen = PAGE_SIZE;
                /*
                 * v3.7 removes VM_RESERVED but the effect is kept by