lkml.org 
[lkml]   [2020]   [Dec]   [29]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH] habanalabs: Fix memleak in hl_device_reset
On Sat, Dec 26, 2020 at 9:32 AM Dinghao Liu <dinghao.liu@zju.edu.cn> wrote:
>
> 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>
> ---
> drivers/misc/habanalabs/common/device.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/misc/habanalabs/common/device.c b/drivers/misc/habanalabs/common/device.c
> index 5871162a8442..e5028890ead1 100644
> --- a/drivers/misc/habanalabs/common/device.c
> +++ b/drivers/misc/habanalabs/common/device.c
> @@ -1092,6 +1092,7 @@ int hl_device_reset(struct hl_device *hdev, bool hard_reset,
> GFP_KERNEL);
> if (!hdev->kernel_ctx) {
> rc = -ENOMEM;
> + hl_mmu_fini(hdev);
> goto out_err;
> }
>
> @@ -1103,6 +1104,7 @@ int hl_device_reset(struct hl_device *hdev, bool hard_reset,
> "failed to init kernel ctx in hard reset\n");
> kfree(hdev->kernel_ctx);
> hdev->kernel_ctx = NULL;
> + hl_mmu_fini(hdev);
> goto out_err;
> }
> }
> --
> 2.17.1
>
Thanks!

This patch is:
Reviewed-by: Oded Gabbay <ogabbay@kernel.org>

Applied to -fixes
Oded

\
 
 \ /
  Last update: 2020-12-29 22:33    [W:0.044 / U:0.492 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site