summaryrefslogtreecommitdiff
path: root/drivers/misc/habanalabs
diff options
context:
space:
mode:
authorOfir Bitton <obitton@habana.ai>2020-11-26 14:01:11 +0300
committerOded Gabbay <ogabbay@kernel.org>2020-11-30 11:47:37 +0300
commit8e718f2eda8d4d2268f1872bd4deddd54900283a (patch)
tree5cf0f2de9591e0a69186fb5baa8ffab88a9c1118 /drivers/misc/habanalabs
parenta63c3fb37b157b56d713a386dc024bf6deb9c7cf (diff)
downloadlinux-8e718f2eda8d4d2268f1872bd4deddd54900283a.tar.xz
habanalabs: free host huge va_range if not used
If huge range is not valid, driver uses the host range also for huge page allocations, but driver never frees its allocation. This introduces a memory leak every time a user closes its context. Signed-off-by: Ofir Bitton <obitton@habana.ai> Reviewed-by: Oded Gabbay <ogabbay@kernel.org> Signed-off-by: Oded Gabbay <ogabbay@kernel.org>
Diffstat (limited to 'drivers/misc/habanalabs')
-rw-r--r--drivers/misc/habanalabs/common/memory.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/drivers/misc/habanalabs/common/memory.c b/drivers/misc/habanalabs/common/memory.c
index 744275dd6410..cbe9da4e0211 100644
--- a/drivers/misc/habanalabs/common/memory.c
+++ b/drivers/misc/habanalabs/common/memory.c
@@ -1761,6 +1761,7 @@ static int vm_ctx_init_with_ranges(struct hl_ctx *ctx,
goto clear_host_va_range;
}
} else {
+ kfree(ctx->va_range[HL_VA_RANGE_TYPE_HOST_HUGE]);
ctx->va_range[HL_VA_RANGE_TYPE_HOST_HUGE] =
ctx->va_range[HL_VA_RANGE_TYPE_HOST];
}
@@ -1906,9 +1907,10 @@ void hl_vm_ctx_fini(struct hl_ctx *ctx)
spin_unlock(&vm->idr_lock);
va_range_fini(hdev, ctx->va_range[HL_VA_RANGE_TYPE_DRAM]);
+ va_range_fini(hdev, ctx->va_range[HL_VA_RANGE_TYPE_HOST]);
+
if (hdev->pmmu_huge_range)
va_range_fini(hdev, ctx->va_range[HL_VA_RANGE_TYPE_HOST_HUGE]);
- va_range_fini(hdev, ctx->va_range[HL_VA_RANGE_TYPE_HOST]);
mutex_destroy(&ctx->mem_hash_lock);
hl_mmu_ctx_fini(ctx);