habanalabs: Fix memleak in hl_device_reset
authorDinghao Liu <dinghao.liu@zju.edu.cn>
Sat, 26 Dec 2020 07:27:14 +0000 (15:27 +0800)
committerOded Gabbay <ogabbay@kernel.org>
Tue, 29 Dec 2020 21:23:12 +0000 (23:23 +0200)
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 <dinghao.liu@zju.edu.cn>
Reviewed-by: Oded Gabbay <ogabbay@kernel.org>
Signed-off-by: Oded Gabbay <ogabbay@kernel.org>
drivers/misc/habanalabs/common/device.c

index 0749c92..1456eab 100644 (file)
@@ -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;
                }
        }