summaryrefslogtreecommitdiffstats
path: root/drivers/misc
diff options
context:
space:
mode:
authorOded Gabbay <oded.gabbay@gmail.com>2020-08-29 11:55:15 +0300
committerOded Gabbay <oded.gabbay@gmail.com>2020-09-22 18:49:51 +0300
commitc5e0ec66f01d6621a64837428efcbbe731d90cd5 (patch)
tree7c3fd221a9cfd20789584e3c5401b9530546b497 /drivers/misc
parent3174ac9bb1045946ff563aa01d679809e87fb2db (diff)
downloadlinux-c5e0ec66f01d6621a64837428efcbbe731d90cd5.tar.bz2
habanalabs: clear vm_pgoff before doing the mmap
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>
Diffstat (limited to 'drivers/misc')
-rw-r--r--drivers/misc/habanalabs/common/command_buffer.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/drivers/misc/habanalabs/common/command_buffer.c b/drivers/misc/habanalabs/common/command_buffer.c
index 68dfbafe3354..6563e4dfe7b6 100644
--- a/drivers/misc/habanalabs/common/command_buffer.c
+++ b/drivers/misc/habanalabs/common/command_buffer.c
@@ -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);