|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] [PATCH v8 04/16] microcode/amd: fix memory leak
On 01.08.2019 12:22, Chao Gao wrote:
> --- a/xen/arch/x86/microcode_amd.c
> +++ b/xen/arch/x86/microcode_amd.c
> @@ -433,6 +433,9 @@ static int cpu_request_microcode(unsigned int cpu, const
> void *buf,
> goto out;
> }
>
> + mc_amd->equiv_cpu_table_size = 0;
> + mc_amd->equiv_cpu_table = NULL;
Instead of adding these, you could as well use xzalloc()
further up and drop the explicit initialization of ->mpb and
->mpb_size to NULL/0 a few lines down.
> @@ -479,6 +482,8 @@ static int cpu_request_microcode(unsigned int cpu, const
> void *buf,
>
> if ( error )
> {
> + if ( mc_amd->equiv_cpu_table_size )
> + xfree(mc_amd->equiv_cpu_table);
Why the if()? There's no problem calling xfree() with a NULL
argument.
> @@ -549,11 +554,14 @@ 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);
> +
> + if ( mc_old->mpb_size )
> + xfree(mc_old->mpb);
> + xfree(mc_old->equiv_cpu_table);
Same here. With the adjustments made (could possibly be done
again while committing)
Reviewed-by: Jan Beulich <jbeulich@xxxxxxxx>
Jan
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |