xen/xsm: flask: Prevent NULL deference in flask_assign_{, dt}device()
authorJulien Grall <julien.grall@arm.com>
Fri, 4 Oct 2019 16:32:49 +0000 (17:32 +0100)
committerJulien Grall <julien.grall@arm.com>
Mon, 7 Oct 2019 09:06:01 +0000 (10:06 +0100)
commit38ad94acf09f6822d6005144935b58228da33a04
tree6a6e5d7ef287d2a90e72480b22f5ecaf64cc280b
parentf4049b2a9850c847b06ec6ad1cec1c7c2c303b94
xen/xsm: flask: Prevent NULL deference in flask_assign_{, dt}device()

flask_assign_{, dt}device() may be used to check whether you can test if
a device is assigned. In this case, the domain will be NULL.

However, flask_iommu_resource_use_perm() will be called and may end up
to deference a NULL pointer. This can be prevented by moving the call
after we check the validity for the domain pointer.

Coverity-ID: 1486741
Fixes: 71e617a6b8 ('use is_iommu_enabled() where appropriate...')
Signed-off-by: Julien Grall <julien.grall@arm.com>
Acked-by: Daniel De Graaf <dgdegra@tycho.nsa.gov>
Reviewed-by: Paul Durrant <paul@xen.org>
Release-acked-by: Juergen Gross <jgross@suse.com>
xen/xsm/flask/hooks.c