VT-d: check bus_to_context_maddr()'s return value

The function returning zero is an error indication; we shouldn't try to
map MFN 0 and then treat that page as a context table.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
Release-Acked-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
This commit is contained in:
Jan Beulich committed 2025-10-13 16:50:01 +02:00
1 parent 4676e09b3c
commit ef5b718cf8
1 file changed
+11
+11
View File
@@ -1499,6 +1499,11 @@ int domain_context_mapping_one(
ASSERT(pcidevs_locked());
spin_lock(&iommu->lock);
maddr = bus_to_context_maddr(iommu, bus);
if ( !maddr )
{
spin_unlock(&iommu->lock);
return -ENOMEM;
}
context_entries = (struct context_entry *)map_vtd_domain_page(maddr);
context = &context_entries[devfn];
old = (lctxt = *context).full;
@@ -1853,6 +1858,12 @@ int domain_context_unmap_one(
spin_lock(&iommu->lock);
maddr = bus_to_context_maddr(iommu, bus);
if ( !maddr )
{
ASSERT_UNREACHABLE();
spin_unlock(&iommu->lock);
return 0;
}
context_entries = (struct context_entry *)map_vtd_domain_page(maddr);
context = &context_entries[devfn];
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.