From 932f26d9d8825261c5a8c78b113efb6cb2ed2036 Mon Sep 17 00:00:00 2001 From: Chao Gao Date: Fri, 30 Aug 2019 10:22:55 +0200 Subject: [PATCH] x86/ucode/AMD: make freeing of old ucode conditional It is certain to be NULL at least the first time through. Reported-by: Sander Eikelenboom Signed-off-by: Chao Gao Reviewed-by: Jan Beulich --- xen/arch/x86/microcode_amd.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/xen/arch/x86/microcode_amd.c b/xen/arch/x86/microcode_amd.c index 306978457b..9b743307c4 100644 --- a/xen/arch/x86/microcode_amd.c +++ b/xen/arch/x86/microcode_amd.c @@ -552,9 +552,12 @@ static int cpu_request_microcode(unsigned int cpu, const void *buf, mc_old = mc_amd; } - xfree(mc_old->mpb); - xfree(mc_old->equiv_cpu_table); - xfree(mc_old); + if ( mc_old ) + { + xfree(mc_old->mpb); + xfree(mc_old->equiv_cpu_table); + xfree(mc_old); + } out: #if CONFIG_HVM -- 2.30.2