Re: [PATCH] KVM: fix error handling in svm_hardware_setup

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On 3/12/19 2:29 AM, Li RongQing wrote:
> From: Li Rongqing <lirongqing@xxxxxxxxx>
> 
> free all memory if fail to setup, otherwise they will be leaked
> 
> Signed-off-by: Li Rongqing <lirongqing@xxxxxxxxx>
> Signed-off-by: Zhang Yu <zhangyu31@xxxxxxxxx>
> ---
>   arch/x86/kvm/svm.c | 6 ++++++
>   1 file changed, 6 insertions(+)
> 
> diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
> index 1787a484d21c..b80a11d99a2a 100644
> --- a/arch/x86/kvm/svm.c
> +++ b/arch/x86/kvm/svm.c
> @@ -1396,6 +1396,12 @@ static __init int svm_hardware_setup(void)
>   	return 0;
>   
>   err:
> +	if (svm_sev_enabled())
> +		bitmap_free(sev_asid_bitmap);
> +
> +	for_each_possible_cpu(cpu)
> +		svm_cpu_uninit(cpu);
> +
>   	__free_pages(iopm_pages, IOPM_ALLOC_ORDER);
>   	iopm_base = 0;
>   	return r;
> 


Does it make sense to call the svm_hardware_unsetup() instead of
duplicating the logic in error code path ?

thanks




[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux