habanalabs: Disable file operations after device is removed
authorTomer Tayar <ttayar@habana.ai>
Mon, 1 Feb 2021 17:44:34 +0000 (19:44 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 10 Mar 2021 08:16:09 +0000 (09:16 +0100)
commitffd123fe839700366ea79b19ac3683bf56817372
treee9e6609d367f132f83f1095b896149bbbcb36db1
parent27ac5aada024e0821c86540ad18f37edadd77d5e
habanalabs: Disable file operations after device is removed

A device can be removed from the PCI subsystem while a process holds the
file descriptor opened.
In such a case, the driver attempts to kill the process, but as it is
still possible that the process will be alive after this step, the
device removal will complete, and we will end up with a process object
that points to a device object which was already released.

To prevent the usage of this released device object, disable the
following file operations for this process object, and avoid the cleanup
steps when the file descriptor is eventually closed.
The latter is just a best effort, as memory leak will occur.

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