acrn-kernel/drivers/vhost
Gautam Dawar 374bcab6c1 vhost-vdpa: free iommu domain after last use during cleanup
[ Upstream commit 5a52215009 ]

Currently vhost_vdpa_cleanup() unmaps the DMA mappings by calling
`iommu_unmap(v->domain, map->start, map->size);`
from vhost_vdpa_general_unmap() when the parent vDPA driver doesn't
provide DMA config operations.

However, the IOMMU domain referred to by `v->domain` is freed in
vhost_vdpa_free_domain() before vhost_vdpa_cleanup() in
vhost_vdpa_release() which results in NULL pointer de-reference.
Accordingly, moving the call to vhost_vdpa_free_domain() in
vhost_vdpa_cleanup() would makes sense. This will also help
detaching the dma device in error handling of vhost_vdpa_alloc_domain().

This issue was observed on terminating QEMU with SIGQUIT.

Fixes: 037d430556 ("vhost-vdpa: call vhost_vdpa_cleanup during the release")
Signed-off-by: Gautam Dawar <gautam.dawar@amd.com>
Message-Id: <20230301163203.29883-1-gautam.dawar@amd.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Acked-by: Jason Wang <jasowang@redhat.com>
Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2023-03-22 13:33:44 +01:00
..
Kconfig
Makefile
iotlb.c
net.c use less confusing names for iov_iter direction initializers 2023-02-09 11:28:04 +01:00
scsi.c vhost-scsi: unbreak any layout for response 2023-02-09 11:28:04 +01:00
test.c
test.h
vdpa.c vhost-vdpa: free iommu domain after last use during cleanup 2023-03-22 13:33:44 +01:00
vhost.c use less confusing names for iov_iter direction initializers 2023-02-09 11:28:04 +01:00
vhost.h vhost/net: Clear the pending messages when the backend is removed 2023-02-09 11:28:03 +01:00
vringh.c use less confusing names for iov_iter direction initializers 2023-02-09 11:28:04 +01:00
vsock.c use less confusing names for iov_iter direction initializers 2023-02-09 11:28:04 +01:00