Commit b000700d authored by Dinghao Liu's avatar Dinghao Liu Committed by Oded Gabbay

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: default avatarDinghao Liu <dinghao.liu@zju.edu.cn>
Reviewed-by: default avatarOded Gabbay <ogabbay@kernel.org>
Signed-off-by: default avatarOded Gabbay <ogabbay@kernel.org>
parent 097c62b6
...@@ -1092,6 +1092,7 @@ int hl_device_reset(struct hl_device *hdev, bool hard_reset, ...@@ -1092,6 +1092,7 @@ int hl_device_reset(struct hl_device *hdev, bool hard_reset,
GFP_KERNEL); GFP_KERNEL);
if (!hdev->kernel_ctx) { if (!hdev->kernel_ctx) {
rc = -ENOMEM; rc = -ENOMEM;
hl_mmu_fini(hdev);
goto out_err; goto out_err;
} }
...@@ -1103,6 +1104,7 @@ int hl_device_reset(struct hl_device *hdev, bool hard_reset, ...@@ -1103,6 +1104,7 @@ int hl_device_reset(struct hl_device *hdev, bool hard_reset,
"failed to init kernel ctx in hard reset\n"); "failed to init kernel ctx in hard reset\n");
kfree(hdev->kernel_ctx); kfree(hdev->kernel_ctx);
hdev->kernel_ctx = NULL; hdev->kernel_ctx = NULL;
hl_mmu_fini(hdev);
goto out_err; goto out_err;
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment