Re: [PATCH v2 3/4] iommufd: Add IOMMU_DEVICE_GET_HW_INFO

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Mar 09, 2023 at 09:50:18PM +0800, Baolu Lu wrote:

> > +	if (cmd->flags || cmd->__reserved || !cmd->data_len)
> > +		return -EOPNOTSUPP;
> > +
> > +	idev = iommufd_get_device(ucmd, cmd->dev_id);
> > +	if (IS_ERR(idev))
> > +		return PTR_ERR(idev);
> > +
> > +	ops = dev_iommu_ops(idev->dev);
> > +	if (!ops || !ops->hw_info) {
> 
> dev_iommu_ops() will never return a NULL.
> 
> Need below check
> 
> 	dev->iommu && dev->iommu->iommu_dev
> 
> before dev_iommu_ops(). Perhaps something like below?
> 
> 	if (!dev->iommu || !dev->iommu->iommu_dev)
> 		return -EINVAL;

At this point the device has become owned through the ownership API,
it absolutely has to have an iommu and an ops. No need to check
anything.

Jason



[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux