Re: Should the return value of the rlookup_amd_iommu be checked?
From: Vasant Hegde
Date: Thu Sep 12 2024 - 00:50:12 EST
Hi,
On 9/12/2024 10:12 AM, Qianqiang Liu wrote:
> 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?
During init driver will initialize rlookup_table. rlookup_amd_iommu will not
return NULL. So its fine.
-Vasant