mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* Should the return value of the rlookup_amd_iommu be checked?
@ 2024-09-12  4:42 Qianqiang Liu
  2024-09-12  4:49 ` Vasant Hegde
  0 siblings, 1 reply; 3+ messages in thread
From: Qianqiang Liu @ 2024-09-12  4:42 UTC (permalink / raw)
  To: suravee.suthikulpanit, will; +Cc: vasant.hegde, iommu, linux-kernel

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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Should the return value of the rlookup_amd_iommu be checked?
  2024-09-12  4:42 Should the return value of the rlookup_amd_iommu be checked? Qianqiang Liu
@ 2024-09-12  4:49 ` Vasant Hegde
  2024-09-12  4:53   ` Qianqiang Liu
  0 siblings, 1 reply; 3+ messages in thread
From: Vasant Hegde @ 2024-09-12  4:49 UTC (permalink / raw)
  To: Qianqiang Liu, suravee.suthikulpanit, will; +Cc: iommu, linux-kernel

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Should the return value of the rlookup_amd_iommu be checked?
  2024-09-12  4:49 ` Vasant Hegde
@ 2024-09-12  4:53   ` Qianqiang Liu
  0 siblings, 0 replies; 3+ messages in thread
From: Qianqiang Liu @ 2024-09-12  4:53 UTC (permalink / raw)
  To: Vasant Hegde; +Cc: suravee.suthikulpanit, will, iommu, linux-kernel

On Thu, Sep 12, 2024 at 10:19:53AM +0530, Vasant Hegde wrote:
> During init driver will initialize rlookup_table. rlookup_amd_iommu will not
> return NULL. So its fine.
> 
> -Vasant

OK, thanks!

-- 
Best,
Qianqiang Liu


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-09-12  4:53 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-09-12  4:42 Should the return value of the rlookup_amd_iommu be checked? Qianqiang Liu
2024-09-12  4:49 ` Vasant Hegde
2024-09-12  4:53   ` Qianqiang Liu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®