]> git.baikalelectronics.ru Git - kernel.git/commit
vhost-vdpa: free iommu domain after last use during cleanup
authorGautam Dawar <gautam.dawar@amd.com>
Wed, 1 Mar 2023 16:32:01 +0000 (22:02 +0530)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 22 Mar 2023 12:33:44 +0000 (13:33 +0100)
commit8103c52657b56215decf56aa08f8e24bbad7b54d
tree323a171a9763d8228c4d3efc90d0664470401aca
parent802725bafa33803568ee28ab52f52b36d46394ba
vhost-vdpa: free iommu domain after last use during cleanup

[ Upstream commit dd42be99e0222d582a98079debf516713c2cf9db ]

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: 9f4cf5306241 ("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>
drivers/vhost/vdpa.c