x86/tboot: check return value of dmar_table allocation
authorHongyan Xia <hongyxia@amazon.com>
Tue, 24 Mar 2020 09:44:22 +0000 (10:44 +0100)
committerJan Beulich <jbeulich@suse.com>
Tue, 24 Mar 2020 09:44:22 +0000 (10:44 +0100)
The allocation can just return NULL. Return an error value early instead
of crashing later on.

Signed-off-by: Hongyan Xia <hongyxia@amazon.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
xen/arch/x86/tboot.c

index 8c232270b411823d1db6be2cb155b453521a11e4..ce85a710dd4dbb9205c0c672b4bfd8572097556e 100644 (file)
@@ -480,6 +480,8 @@ int __init tboot_parse_dmar_table(acpi_table_handler dmar_handler)
                       sizeof(dmar_table_length),
                       pa + sizeof(char) * ACPI_NAME_SIZE);
     dmar_table = xmalloc_bytes(dmar_table_length);
+    if ( !dmar_table )
+        return -ENOMEM;
     tboot_copy_memory(dmar_table, dmar_table_length, pa);
     clear_fixmap(FIX_TBOOT_MAP_ADDRESS);