Skip to content

Commit 47f2bd2

Browse files
committed
iommufd/selftest: Check the bus type during probe
This relied on the probe function only being invoked by the bus type mock was registered on. The removal of the bus ops broke this assumption and the probe could be called on non-mock bus types like PCI. Check the bus type directly in probe. Fixes: 17de3f5 ("iommu: Retire bus ops") Link: https://lore.kernel.org/r/0-v1-82d59f7eab8c+40c-iommufd_mock_bus_jgg@nvidia.com Reviewed-by: Kevin Tian <kevin.tian@intel.com> Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
1 parent f6f3721 commit 47f2bd2

1 file changed

Lines changed: 15 additions & 13 deletions

File tree

drivers/iommu/iommufd/selftest.c

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,19 @@ static struct iommu_domain_ops domain_nested_ops;
2525

2626
size_t iommufd_test_memory_limit = 65536;
2727

28+
struct mock_bus_type {
29+
struct bus_type bus;
30+
struct notifier_block nb;
31+
};
32+
33+
static struct mock_bus_type iommufd_mock_bus_type = {
34+
.bus = {
35+
.name = "iommufd_mock",
36+
},
37+
};
38+
39+
static atomic_t mock_dev_num;
40+
2841
enum {
2942
MOCK_DIRTY_TRACK = 1,
3043
MOCK_IO_PAGE_SIZE = PAGE_SIZE / 2,
@@ -437,6 +450,8 @@ static struct iommu_device mock_iommu_device = {
437450

438451
static struct iommu_device *mock_probe_device(struct device *dev)
439452
{
453+
if (dev->bus != &iommufd_mock_bus_type.bus)
454+
return ERR_PTR(-ENODEV);
440455
return &mock_iommu_device;
441456
}
442457

@@ -576,19 +591,6 @@ get_md_pagetable_nested(struct iommufd_ucmd *ucmd, u32 mockpt_id,
576591
return hwpt;
577592
}
578593

579-
struct mock_bus_type {
580-
struct bus_type bus;
581-
struct notifier_block nb;
582-
};
583-
584-
static struct mock_bus_type iommufd_mock_bus_type = {
585-
.bus = {
586-
.name = "iommufd_mock",
587-
},
588-
};
589-
590-
static atomic_t mock_dev_num;
591-
592594
static void mock_dev_release(struct device *dev)
593595
{
594596
struct mock_dev *mdev = container_of(dev, struct mock_dev, dev);

0 commit comments

Comments
 (0)