]> git.baikalelectronics.ru Git - kernel.git/commit
iommu/virtio: Fix freeing of incomplete domains
authorJean-Philippe Brucker <jean-philippe@linaro.org>
Thu, 26 Mar 2020 09:35:57 +0000 (10:35 +0100)
committerJoerg Roedel <jroedel@suse.de>
Fri, 27 Mar 2020 10:09:19 +0000 (11:09 +0100)
commit92b616657d1a266ed82cf5a7be98746328e09474
tree626fea3935ff83ce8d3ae19d18ef587d7a9ee97c
parent11e7b2ae43a6e1338c2f2d5c9963fbda396a844e
iommu/virtio: Fix freeing of incomplete domains

Calling viommu_domain_free() on a domain that hasn't been finalised (not
attached to any device, for example) can currently cause an Oops,
because we attempt to call ida_free() on ID 0, which may either be
unallocated or used by another domain.

Only initialise the vdomain->viommu pointer, which denotes a finalised
domain, at the end of a successful viommu_domain_finalise().

Fixes: 481395a84256 ("iommu: Add virtio-iommu driver")
Reported-by: Eric Auger <eric.auger@redhat.com>
Signed-off-by: Jean-Philippe Brucker <jean-philippe@linaro.org>
Reviewed-by: Robin Murphy <robin.murphy@arm.com>
Link: https://lore.kernel.org/r/20200326093558.2641019-3-jean-philippe@linaro.org
Signed-off-by: Joerg Roedel <jroedel@suse.de>
drivers/iommu/virtio-iommu.c