Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

xen/grant-dma-iommu: Implement a dummy probe_device() callback

Update stub IOMMU driver (which main purpose is to reuse generic
IOMMU device-tree bindings by Xen grant DMA-mapping layer on Arm)
according to the recent changes done in the following
commit 57365a04c921 ("iommu: Move bus setup to IOMMU device registration").

With probe_device() callback being called during IOMMU device registration,
the uninitialized callback just leads to the "kernel NULL pointer
dereference" issue during boot. Fix that by adding a dummy callback.

Looks like the release_device() callback is not mandatory to be
implemented as IOMMU framework makes sure that callback is initialized
before dereferencing.

Reported-by: Viresh Kumar <viresh.kumar@linaro.org>
Fixes: 57365a04c921 ("iommu: Move bus setup to IOMMU device registration")
Signed-off-by: Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com>
Tested-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
Link: https://lore.kernel.org/r/20230208153649.3604857-1-olekstysh@gmail.com
Signed-off-by: Juergen Gross <jgross@suse.com>

authored by

Oleksandr Tyshchenko and committed by
Juergen Gross
2062f9fb c70b7741

+9 -2
+9 -2
drivers/xen/grant-dma-iommu.c
··· 16 16 struct iommu_device iommu; 17 17 }; 18 18 19 - /* Nothing is really needed here */ 20 - static const struct iommu_ops grant_dma_iommu_ops; 19 + static struct iommu_device *grant_dma_iommu_probe_device(struct device *dev) 20 + { 21 + return ERR_PTR(-ENODEV); 22 + } 23 + 24 + /* Nothing is really needed here except a dummy probe_device callback */ 25 + static const struct iommu_ops grant_dma_iommu_ops = { 26 + .probe_device = grant_dma_iommu_probe_device, 27 + }; 21 28 22 29 static const struct of_device_id grant_dma_iommu_of_match[] = { 23 30 { .compatible = "xen,grant-dma" },