habanalabs: fix dma-buf release handling if dma_buf_fd() fails
authorTomer Tayar <ttayar@habana.ai>
Thu, 15 Dec 2022 14:36:53 +0000 (16:36 +0200)
committerOded Gabbay <ogabbay@kernel.org>
Thu, 26 Jan 2023 08:56:22 +0000 (10:56 +0200)
commit9b3d9f917f81aed559d19377c11d6fac3db89fd7
tree640657ae7bdd2acda6b1130687db481c2cac0208
parent6bdb7bc990cbed81f703c4a265843f959359489c
habanalabs: fix dma-buf release handling if dma_buf_fd() fails

The dma-buf private object is freed if a call to dma_buf_fd() fails,
and because a file was already associated with the dma-buf in
dma_buf_export(), the release op will be called and will use this
object.

Mark the 'priv' field as NULL in this case, and avoid accessing it from
the release op.

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/memory.c