]> git.baikalelectronics.ru Git - kernel.git/commit
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)
commitb4430fe223c00d09c794fbbc3571f0ea2b260455
treee9e6609d367f132f83f1095b896149bbbcb36db1
parent0d38bfc2f47aaa17313cc0d18e35f64ffea00676
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