xen/iommu: Check if the IOMMU was initialized before tearing down
authorJulien Grall <jgrall@amazon.com>
Fri, 5 Mar 2021 14:33:27 +0000 (15:33 +0100)
committerJan Beulich <jbeulich@suse.com>
Fri, 5 Mar 2021 14:33:27 +0000 (15:33 +0100)
commit605e1d92efa0a00e81396fd7510046ed38bd9197
tree2c94ea153016d10697c988b2e1f1fb67b6d43b8f
parent865eba02a1ec10972edbeb403b492e45e391f509
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>
master commit: d670ef3401b91d04c58d72cd8ce5579b4fa900d8
master date: 2021-02-17 11:30:05 +0000
xen/drivers/passthrough/iommu.c