All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Dinghao Liu <dinghao.liu@zju.edu.cn>,
	Oded Gabbay <ogabbay@kernel.org>, Sasha Levin <sashal@kernel.org>
Subject: [PATCH AUTOSEL 5.4 12/28] habanalabs: Fix memleak in hl_device_reset
Date: Tue, 12 Jan 2021 07:56:28 -0500	[thread overview]
Message-ID: <20210112125645.70739-12-sashal@kernel.org> (raw)
In-Reply-To: <20210112125645.70739-1-sashal@kernel.org>

From: Dinghao Liu <dinghao.liu@zju.edu.cn>

[ Upstream commit b000700d6db50c933ce8b661154e26cf4ad06dba ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/misc/habanalabs/device.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/misc/habanalabs/device.c b/drivers/misc/habanalabs/device.c
index 3eeb1920ddb43..3486bf33474d9 100644
--- a/drivers/misc/habanalabs/device.c
+++ b/drivers/misc/habanalabs/device.c
@@ -959,6 +959,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;
 		}
 
@@ -970,6 +971,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.27.0


  parent reply	other threads:[~2021-01-12 13:12 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-12 12:56 [PATCH AUTOSEL 5.4 01/28] ARC: build: remove non-existing bootpImage from KBUILD_IMAGE Sasha Levin
2021-01-12 12:56 ` Sasha Levin
2021-01-12 12:56 ` [PATCH AUTOSEL 5.4 02/28] ARC: build: add uImage.lzma to the top-level target Sasha Levin
2021-01-12 12:56   ` Sasha Levin
2021-01-12 12:56 ` [PATCH AUTOSEL 5.4 03/28] ARC: build: add boot_targets to PHONY Sasha Levin
2021-01-12 12:56   ` Sasha Levin
2021-01-12 12:56 ` [PATCH AUTOSEL 5.4 04/28] ARC: build: move symlink creation to arch/arc/Makefile to avoid race Sasha Levin
2021-01-12 12:56   ` Sasha Levin
2021-01-12 12:56 ` [PATCH AUTOSEL 5.4 05/28] netfilter: ipset: fixes possible oops in mtype_resize Sasha Levin
2021-01-12 12:56 ` [PATCH AUTOSEL 5.4 06/28] btrfs: fix transaction leak and crash after RO remount caused by qgroup rescan Sasha Levin
2021-01-12 12:56 ` [PATCH AUTOSEL 5.4 07/28] regulator: bd718x7: Add enable times Sasha Levin
2021-01-12 12:56 ` [PATCH AUTOSEL 5.4 08/28] ethernet: ucc_geth: fix definition and size of ucc_geth_tx_global_pram Sasha Levin
2021-01-12 12:56   ` Sasha Levin
2021-01-12 12:56 ` [PATCH AUTOSEL 5.4 09/28] qede: fix offload for IPIP tunnel packets Sasha Levin
2021-01-12 12:56 ` [PATCH AUTOSEL 5.4 10/28] habanalabs: register to pci shutdown callback Sasha Levin
2021-01-12 12:56 ` [PATCH AUTOSEL 5.4 11/28] CDC-NCM: remove "connected" log message Sasha Levin
2021-01-12 12:56 ` Sasha Levin [this message]
2021-01-12 12:56 ` [PATCH AUTOSEL 5.4 13/28] hwmon: (pwm-fan) Ensure that calculation doesn't discard big period values Sasha Levin
2021-01-12 12:56 ` [PATCH AUTOSEL 5.4 14/28] lib/raid6: Let $(UNROLL) rules work with macOS userland Sasha Levin
2021-01-12 12:56 ` [PATCH AUTOSEL 5.4 15/28] dmaengine: stm32-mdma: fix STM32_MDMA_VERY_HIGH_PRIORITY value Sasha Levin
2021-01-12 12:56   ` Sasha Levin
2021-01-12 12:56 ` [PATCH AUTOSEL 5.4 16/28] net: usb: qmi_wwan: add Quectel EM160R-GL Sasha Levin
2021-01-12 12:56 ` [PATCH AUTOSEL 5.4 17/28] bfq: Fix computation of shallow depth Sasha Levin
2021-01-12 12:56 ` [PATCH AUTOSEL 5.4 18/28] arch/arc: add copy_user_page() to <asm/page.h> to fix build error on ARC Sasha Levin
2021-01-12 12:56   ` Sasha Levin
2021-01-12 12:56   ` Sasha Levin
2021-01-12 12:56 ` [PATCH AUTOSEL 5.4 19/28] misdn: dsp: select CONFIG_BITREVERSE Sasha Levin
2021-01-12 12:56 ` [PATCH AUTOSEL 5.4 20/28] net: ethernet: fs_enet: Add missing MODULE_LICENSE Sasha Levin
2021-01-12 12:56   ` Sasha Levin
2021-01-12 12:56 ` [PATCH AUTOSEL 5.4 21/28] selftests: fix the return value for UDP GRO test Sasha Levin
2021-01-12 12:56 ` [PATCH AUTOSEL 5.4 22/28] nvme-pci: mark Samsung PM1725a as IGNORE_DEV_SUBNQN Sasha Levin
2021-01-12 12:56   ` Sasha Levin
2021-01-12 12:56 ` [PATCH AUTOSEL 5.4 23/28] nvmet-rdma: Fix list_del corruption on queue establishment failure Sasha Levin
2021-01-12 12:56   ` Sasha Levin
2021-01-12 12:56 ` [PATCH AUTOSEL 5.4 24/28] drm/amdgpu: fix a GPU hang issue when remove device Sasha Levin
2021-01-12 12:56   ` Sasha Levin
2021-01-12 12:56   ` Sasha Levin
2021-01-12 12:56 ` [PATCH AUTOSEL 5.4 25/28] usb: typec: Fix copy paste error for NVIDIA alt-mode description Sasha Levin
2021-01-12 12:56 ` [PATCH AUTOSEL 5.4 26/28] ACPI: scan: add stub acpi_create_platform_device() for !CONFIG_ACPI Sasha Levin
2021-01-12 12:56 ` [PATCH AUTOSEL 5.4 27/28] drm/msm: Call msm_init_vram before binding the gpu Sasha Levin
2021-01-12 12:56   ` Sasha Levin
2021-01-12 12:56 ` [PATCH AUTOSEL 5.4 28/28] ARM: picoxcell: fix missing interrupt-parent properties Sasha Levin
2021-01-12 12:56   ` Sasha Levin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210112125645.70739-12-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=dinghao.liu@zju.edu.cn \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ogabbay@kernel.org \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.