iommu: Check dev->iommu in iommu_dev_xxx functions
authorShameer Kolothum <shameerali.kolothum.thodi@huawei.com>
Wed, 3 Mar 2021 17:36:11 +0000 (17:36 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 14 May 2021 07:50:29 +0000 (09:50 +0200)
commitb60e13c306884e18c17498ca62353645bced9138
tree466796de707f833bd0825d624a8efb5cd789a767
parent3d15bf2b2c93dd606da7a3c163a56ef91d802463
iommu: Check dev->iommu in iommu_dev_xxx functions

[ Upstream commit b9abb19fa5fd2d8a4be61c6cd4b2a48aa1a17f9c ]

The device iommu probe/attach might have failed leaving dev->iommu
to NULL and device drivers may still invoke these functions resulting
in a crash in iommu vendor driver code.

Hence make sure we check that.

Fixes: a3a195929d40 ("iommu: Add APIs for multiple domains per device")
Signed-off-by: Shameer Kolothum <shameerali.kolothum.thodi@huawei.com>
Reviewed-by: Robin Murphy <robin.murphy@arm.com>
Link: https://lore.kernel.org/r/20210303173611.520-1-shameerali.kolothum.thodi@huawei.com
Signed-off-by: Joerg Roedel <jroedel@suse.de>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/iommu/iommu.c