diff options
author | Yuri Nudelman <ynudelman@habana.ai> | 2022-05-15 13:46:37 +0300 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2022-05-22 21:01:21 +0200 |
commit | f873a27fd50d161111d0e52087af0f5b2111c5c4 (patch) | |
tree | f3f8a4e7de88e607304501b815734a047493062e /drivers/misc | |
parent | e31dd9362f01682192d80221cc4339e4f7140f30 (diff) | |
download | linux-f873a27fd50d161111d0e52087af0f5b2111c5c4.tar.gz |
habanalabs: fix missing handle shift during mmap
During mmap operation on the unified memory manager buffer, the vma
page offset is shifted to extract the handle value. Due to a typo, it
was not shifted back at the end. That could cause the offset to be
modified after mmap operation, that may affect subsequent operations.
In addition, in allocation flow, in case of out of memory error, idr
would not be correctly destroyed, again because of a missing shift.
Signed-off-by: Yuri Nudelman <ynudelman@habana.ai>
Reviewed-by: Oded Gabbay <ogabbay@kernel.org>
Signed-off-by: Oded Gabbay <ogabbay@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/misc')
-rw-r--r-- | drivers/misc/habanalabs/common/memory_mgr.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/misc/habanalabs/common/memory_mgr.c b/drivers/misc/habanalabs/common/memory_mgr.c index 3dbe388d592d..ea5f2bd31b0a 100644 --- a/drivers/misc/habanalabs/common/memory_mgr.c +++ b/drivers/misc/habanalabs/common/memory_mgr.c @@ -183,7 +183,7 @@ hl_mmap_mem_buf_alloc(struct hl_mem_mgr *mmg, remove_idr: spin_lock(&mmg->lock); - idr_remove(&mmg->handles, buf->handle); + idr_remove(&mmg->handles, lower_32_bits(buf->handle >> PAGE_SHIFT)); spin_unlock(&mmg->lock); free_buf: kfree(buf); @@ -295,7 +295,7 @@ int hl_mem_mgr_mmap(struct hl_mem_mgr *mmg, struct vm_area_struct *vma, } buf->real_mapped_size = buf->mappable_size; - vma->vm_pgoff = handle; + vma->vm_pgoff = handle >> PAGE_SHIFT; return 0; |