Should the return value of the rlookup_amd_iommu be checked?

From: Qianqiang Liu
Date: Thu Sep 12 2024 - 00:43:22 EST


Hi,

I reviewed the following code:

1592 void amd_iommu_update_and_flush_device_table(struct protection_domain *domain)
1593 {
1594 struct iommu_dev_data *dev_data;
1595
1596 list_for_each_entry(dev_data, &domain->dev_list, list) {
1597 struct amd_iommu *iommu = rlookup_amd_iommu(dev_data->dev); <-
1598
1599 set_dte_entry(iommu, dev_data); <-
1600 clone_aliases(iommu, dev_data->dev);
1601 }
1602
1603 list_for_each_entry(dev_data, &domain->dev_list, list)
1604 device_flush_dte(dev_data);
1605
1606 domain_flush_complete(domain);
1607 }

The "rlookup_amd_iommu" function may return NULL, and the "set_dte_entry" function
will call "get_dev_table" which will dereference the NULL pointer.

Is this an issue that may cause panic? Or will "rlookup_amd_iommu" function never
return NULL?

--
Best,
Qianqiang Liu