On 01.09.20 04:02, Lu Baolu wrote:
[...]
> This looks more like a generic issue, used-before-allocated, and should
> be fixed in iommu.c instead of VT-d driver. How about
>
> diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
> index 8fd93a5b8764..a599da87eb60 100644
> --- a/drivers/iommu/iommu.c
> +++ b/drivers/iommu/iommu.c
> @@ -190,6 +190,28 @@ static void dev_iommu_free(struct device *dev)
> dev->iommu = NULL;
> }
>
> +void *dev_iommu_priv_get(struct device *dev)
> +{
> + struct dev_iommu *param = dev_iommu_get(dev);
> +
> + if (WARN_ON(!param))
> + return ERR_PTR(-ENOMEM);
> +
> + return param->priv;
> +}
> +EXPORT_SYMBOL_GPL(dev_iommu_priv_get);
> +
> +void dev_iommu_priv_set(struct device *dev, void *priv)
> +{
> + struct dev_iommu *param = dev_iommu_get(dev);
> +
> + if (WARN_ON(!param))
> + return;
> +
> + param->priv = priv;
> +}
> +EXPORT_SYMBOL_GPL(dev_iommu_priv_set);
> +
This fix would work in my case. I tested it with slight modification to
replace the inline routines in include/linux/iommu.h.
The WARN_ON was not triggered during my tests. However, looking at the
definition of dev_iommu_get this is to be expected.
Regards,
Torsten
_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu