habanalabs: clear vm_pgoff before doing the mmap
authorOded Gabbay <oded.gabbay@gmail.com>
Sat, 29 Aug 2020 08:55:15 +0000 (11:55 +0300)
committerOded Gabbay <oded.gabbay@gmail.com>
Tue, 22 Sep 2020 15:49:51 +0000 (18:49 +0300)
The driver use vm_pgoff to hold the CB idr handle. Before we actually call
the mapping function, we need to clear the handle so there won't be any
garbage left in vm_pgoff.

Signed-off-by: Oded Gabbay <oded.gabbay@gmail.com>
drivers/misc/habanalabs/common/command_buffer.c

index 68dfbafe3354954ebd798abbeecfcc413d4bbf4a..6563e4dfe7b6292640df68e396dd9745054ff510 100644 (file)
@@ -304,7 +304,11 @@ int hl_cb_mmap(struct hl_fpriv *hpriv, struct vm_area_struct *vma)
        u32 handle, user_cb_size;
        int rc;
 
+       /* We use the page offset to hold the idr and thus we need to clear
+        * it before doing the mmap itself
+        */
        handle = vma->vm_pgoff;
+       vma->vm_pgoff = 0;
 
        /* reference was taken here */
        cb = hl_cb_get(hdev, &hpriv->cb_mgr, handle);