[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen staging] microcode/amd: fix memory leak
commit de45e3ff37bb1602796054afabfa626ea5661c45 Author: Chao Gao <chao.gao@xxxxxxxxx> AuthorDate: Wed Aug 28 16:52:18 2019 +0200 Commit: Jan Beulich <jbeulich@xxxxxxxx> CommitDate: Wed Aug 28 16:52:18 2019 +0200 microcode/amd: fix memory leak Two buffers, '->equiv_cpu_table' and '->mpb', inside 'mc_amd' might be allocated and in the error-handing path they are not freed properly. Signed-off-by: Chao Gao <chao.gao@xxxxxxxxx> Reviewed-by: Jan Beulich <jbeulich@xxxxxxxx> --- xen/arch/x86/microcode_amd.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/xen/arch/x86/microcode_amd.c b/xen/arch/x86/microcode_amd.c index 7a854c012f..306978457b 100644 --- a/xen/arch/x86/microcode_amd.c +++ b/xen/arch/x86/microcode_amd.c @@ -425,7 +425,7 @@ static int cpu_request_microcode(unsigned int cpu, const void *buf, goto out; } - mc_amd = xmalloc(struct microcode_amd); + mc_amd = xzalloc(struct microcode_amd); if ( !mc_amd ) { printk(KERN_ERR "microcode: Cannot allocate memory for microcode patch\n"); @@ -479,6 +479,7 @@ static int cpu_request_microcode(unsigned int cpu, const void *buf, if ( error ) { + xfree(mc_amd->equiv_cpu_table); xfree(mc_amd); goto out; } @@ -491,8 +492,6 @@ static int cpu_request_microcode(unsigned int cpu, const void *buf, * It's possible the data file has multiple matching ucode, * lets keep searching till the latest version */ - mc_amd->mpb = NULL; - mc_amd->mpb_size = 0; last_offset = offset; while ( (error = get_ucode_from_buffer_amd(mc_amd, buf, bufsize, &offset)) == 0 ) @@ -549,11 +548,13 @@ static int cpu_request_microcode(unsigned int cpu, const void *buf, if ( save_error ) { - xfree(mc_amd); uci->mc.mc_amd = mc_old; + mc_old = mc_amd; } - else - xfree(mc_old); + + xfree(mc_old->mpb); + xfree(mc_old->equiv_cpu_table); + xfree(mc_old); out: #if CONFIG_HVM -- generated by git-patchbot for /home/xen/git/xen.git#staging _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxxxxxxxxx https://lists.xenproject.org/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |