[Xen-devel] [PATCH] x86/tboot: check return value of dmar_table allocation

Hongyan Xia posted 1 patch 3 weeks ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/xen tags/patchew/bd60c61a1e7eb0bafa1ed60f87ab144ae4d34c1f.1584379843.git.hongyxia@amazon.com
xen/arch/x86/tboot.c | 2 ++
1 file changed, 2 insertions(+)

[Xen-devel] [PATCH] x86/tboot: check return value of dmar_table allocation

Posted by Hongyan Xia 3 weeks ago
From: Hongyan Xia <hongyxia@amazon.com>

The allocation can just return NULL. Return an error value early instead
of crashing later on.

Signed-off-by: Hongyan Xia <hongyxia@amazon.com>
---
 xen/arch/x86/tboot.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/xen/arch/x86/tboot.c b/xen/arch/x86/tboot.c
index 8c232270b4..ce85a710dd 100644
--- a/xen/arch/x86/tboot.c
+++ b/xen/arch/x86/tboot.c
@@ -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);
 
-- 
2.17.1


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

Re: [Xen-devel] [PATCH] x86/tboot: check return value of dmar_table allocation

Posted by Jan Beulich 3 weeks ago
On 16.03.2020 18:30, Hongyan Xia wrote:
> From: Hongyan Xia <hongyxia@amazon.com>
> 
> The allocation can just return NULL. Return an error value early instead
> of crashing later on.

Not very likely, and we'll be in bigger trouble in such a case, but
yes.

> Signed-off-by: Hongyan Xia <hongyxia@amazon.com>

Reviewed-by: Jan Beulich <jbeulich@suse.com>

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel