diff options
author | Oded Gabbay <ogabbay@kernel.org> | 2021-01-11 14:00:38 +0100 |
---|---|---|
committer | Oded Gabbay <ogabbay@kernel.org> | 2021-01-12 13:59:52 +0100 |
commit | aa6df6533b8f9ead98889baa92e2b19793b1c77e (patch) | |
tree | 592984f950d9ffe10b1466a9ddc4d24a4ac24fd4 /drivers/misc/habanalabs/common/device.c | |
parent | habanalabs: fix dma_addr passed to dma_mmap_coherent (diff) | |
download | linux-aa6df6533b8f9ead98889baa92e2b19793b1c77e.tar.xz linux-aa6df6533b8f9ead98889baa92e2b19793b1c77e.zip |
habanalabs: fix reset process in case of failures
There are some points in the reset process where if the code fails
for some reason, and the system admin tries to initiate the reset
process again we will get a kernel panic.
This is because there aren't any protections in different fini
functions that are called during the reset process.
The protections that are added in this patch make sure that if the fini
functions are called multiple times, without calling init functions
between them, there won't be double release of already released
resources.
Signed-off-by: Oded Gabbay <ogabbay@kernel.org>
Diffstat (limited to 'drivers/misc/habanalabs/common/device.c')
-rw-r--r-- | drivers/misc/habanalabs/common/device.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/misc/habanalabs/common/device.c b/drivers/misc/habanalabs/common/device.c index 1456eabf9601..1ea57d86caa3 100644 --- a/drivers/misc/habanalabs/common/device.c +++ b/drivers/misc/habanalabs/common/device.c @@ -1037,7 +1037,7 @@ kill_processes: if (hard_reset) { /* Release kernel context */ - if (hl_ctx_put(hdev->kernel_ctx) == 1) + if (hdev->kernel_ctx && hl_ctx_put(hdev->kernel_ctx) == 1) hdev->kernel_ctx = NULL; hl_vm_fini(hdev); hl_mmu_fini(hdev); |