drivers/iommu: Take a ref to the IOMMU driver prior to ->add_device()
authorWill Deacon <will@kernel.org>
Thu, 19 Dec 2019 12:03:41 +0000 (12:03 +0000)
committerJoerg Roedel <jroedel@suse.de>
Mon, 23 Dec 2019 13:06:05 +0000 (14:06 +0100)
commit25f003de987aed630db265ceae9cd978537a3f80
tree6a53d13ae038b397f968766a1a5c7fa9b1b5fc71
parent1a373a78b8e2fae1d61dd9c5ed22472045d83d24
drivers/iommu: Take a ref to the IOMMU driver prior to ->add_device()

To avoid accidental removal of an active IOMMU driver module, take a
reference to the driver module in 'iommu_probe_device()' immediately
prior to invoking the '->add_device()' callback and hold it until the
after the device has been removed by '->remove_device()'.

Suggested-by: Joerg Roedel <joro@8bytes.org>
Signed-off-by: Will Deacon <will@kernel.org>
Tested-by: John Garry <john.garry@huawei.com> # smmu v3
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Joerg Roedel <jroedel@suse.de>
drivers/iommu/iommu.c
include/linux/iommu.h