xen/iommu: Check if the IOMMU was initialized before tearing down
authorJulien Grall <jgrall@amazon.com>
Thu, 17 Dec 2020 12:27:21 +0000 (12:27 +0000)
committerJulien Grall <jgrall@amazon.com>
Wed, 17 Feb 2021 11:30:05 +0000 (11:30 +0000)
commitd670ef3401b91d04c58d72cd8ce5579b4fa900d8
treee4552f9d6d5409cb04c0fc20fa46292cbaced538
parent3b1cc15f1931ba56d0ee256fe9bfe65509733b27
xen/iommu: Check if the IOMMU was initialized before tearing down

is_iommu_enabled() will return true even if the IOMMU has not been
initialized (e.g. the ops are not set).

In the case of an early failure in arch_domain_init(), the function
iommu_destroy_domain() will be called even if the IOMMU is not
initialized.

This will result to dereference the ops which will be NULL and an host
crash.

Fix the issue by checking that ops has been set before accessing it.

Fixes: 71e617a6b8f6 ("use is_iommu_enabled() where appropriate...")
Signed-off-by: Julien Grall <jgrall@amazon.com>
Reviewed-by: Paul Durrant <paul@xen.org>
xen/drivers/passthrough/iommu.c