From: Dinghao Liu Date: Sat, 26 Dec 2020 07:27:14 +0000 (+0800) Subject: habanalabs: Fix memleak in hl_device_reset X-Git-Tag: v5.11-rc3~7^2~5^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=b000700d6db50c933ce8b661154e26cf4ad06dba;p=thirdparty%2Flinux.git habanalabs: Fix memleak in hl_device_reset When kzalloc() fails, we should execute hl_mmu_fini() to release the MMU module. It's the same when hl_ctx_init() fails. Signed-off-by: Dinghao Liu Reviewed-by: Oded Gabbay Signed-off-by: Oded Gabbay --- diff --git a/drivers/misc/habanalabs/common/device.c b/drivers/misc/habanalabs/common/device.c index 0749c92cbcf63..1456eabf96010 100644 --- a/drivers/misc/habanalabs/common/device.c +++ b/drivers/misc/habanalabs/common/device.c @@ -1092,6 +1092,7 @@ kill_processes: GFP_KERNEL); if (!hdev->kernel_ctx) { rc = -ENOMEM; + hl_mmu_fini(hdev); goto out_err; } @@ -1103,6 +1104,7 @@ kill_processes: "failed to init kernel ctx in hard reset\n"); kfree(hdev->kernel_ctx); hdev->kernel_ctx = NULL; + hl_mmu_fini(hdev); goto out_err; } }