On 2/15/22 9:46 AM, Lu Baolu wrote:
On 2/14/22 8:49 PM, Joerg Roedel wrote:
On Mon, Feb 14, 2022 at 09:55:35AM +0800, Lu Baolu wrote:
+static inline const struct iommu_ops *dev_iommu_ops(struct device *dev)
+{
+ /*
+ * Assume that valid ops must be installed if iommu_probe_device()
+ * has succeeded. The device ops are essentially for internal use
+ * within the IOMMU subsystem itself, so we should be able to trust
+ * ourselves not to misuse the helper.
+ */
+ WARN_ON(!dev || !dev->iommu || !dev->iommu->iommu_dev ||
+ !dev->iommu->iommu_dev->ops);
There is no need for this WARN_ON, the code will oops anyway when one of
the pointers checked here is NULL.
We really don't need to WARN_ON intermediate null pointers. But I would
argue that we could add a WARN() on null dev->iommu->iommu_dev->ops, so
that callers have no need to check the returned ops.
Oh, sorry! We don't need to check null ops either. That will also result
in a null pointer reference oops in the caller.
So, yes. No need for this WARN_ON().
Best regards,
baolu
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu