[PATCH AUTOSEL 5.9 10/23] habanalabs: free host huge va_range if not used
From: Sasha Levin
Date: Sat Dec 12 2020 - 11:24:40 EST
From: Ofir Bitton <obitton@xxxxxxxxx>
[ Upstream commit c8c39fbd01d42c30454e42c16bcd69c17260b90a ]
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@xxxxxxxxx>
Reviewed-by: Oded Gabbay <ogabbay@xxxxxxxxxx>
Signed-off-by: Oded Gabbay <ogabbay@xxxxxxxxxx>
Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>
---
drivers/misc/habanalabs/common/memory.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/misc/habanalabs/common/memory.c b/drivers/misc/habanalabs/common/memory.c
index 5ff4688683fd3..7b839189c0161 100644
--- a/drivers/misc/habanalabs/common/memory.c
+++ b/drivers/misc/habanalabs/common/memory.c
@@ -1616,6 +1616,7 @@ static int vm_ctx_init_with_ranges(struct hl_ctx *ctx,
goto host_hpage_range_err;
}
} else {
+ kfree(ctx->host_huge_va_range);
ctx->host_huge_va_range = ctx->host_va_range;
}
--
2.27.0