]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commit
accel/habanalabs: postpone mem_mgr IDR destruction to hpriv_release()
authorTomer Tayar <ttayar@habana.ai>
Wed, 1 Mar 2023 15:45:58 +0000 (17:45 +0200)
committerOded Gabbay <ogabbay@kernel.org>
Wed, 15 Mar 2023 11:29:15 +0000 (13:29 +0200)
commit2e8e9a895c4589f124a37fc84d123b5114406e94
tree89af56f451be54058dc9e332106c26239f43fe98
parent801507d3b31489d8a834eab443987a562e2e1e41
accel/habanalabs: postpone mem_mgr IDR destruction to hpriv_release()

The memory manager IDR is currently destroyed when user releases the
file descriptor.
However, at this point the user context might be still held, and memory
buffers might be still in use.
Later on, calls to release those buffers will fail due to not finding
their handles in the IDR, leading to a memory leak.
To avoid this leak, split the IDR destruction from the memory manager
fini, and postpone it to hpriv_release() when there is no user context
and no buffers are used.

Signed-off-by: Tomer Tayar <ttayar@habana.ai>
Reviewed-by: Oded Gabbay <ogabbay@kernel.org>
Signed-off-by: Oded Gabbay <ogabbay@kernel.org>
drivers/accel/habanalabs/common/device.c
drivers/accel/habanalabs/common/habanalabs.h
drivers/accel/habanalabs/common/habanalabs_drv.c
drivers/accel/habanalabs/common/memory_mgr.c