Skip to content

Commit b000700

Browse files
dinghaoliuogabbay
authored andcommitted
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 <[email protected]> Reviewed-by: Oded Gabbay <[email protected]> Signed-off-by: Oded Gabbay <[email protected]>
1 parent 097c62b commit b000700

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

drivers/misc/habanalabs/common/device.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1092,6 +1092,7 @@ int hl_device_reset(struct hl_device *hdev, bool hard_reset,
10921092
GFP_KERNEL);
10931093
if (!hdev->kernel_ctx) {
10941094
rc = -ENOMEM;
1095+
hl_mmu_fini(hdev);
10951096
goto out_err;
10961097
}
10971098

@@ -1103,6 +1104,7 @@ int hl_device_reset(struct hl_device *hdev, bool hard_reset,
11031104
"failed to init kernel ctx in hard reset\n");
11041105
kfree(hdev->kernel_ctx);
11051106
hdev->kernel_ctx = NULL;
1107+
hl_mmu_fini(hdev);
11061108
goto out_err;
11071109
}
11081110
}

0 commit comments

Comments
 (0)