hv: avoid memory leak in init_msr_emulation
If the vcpu->guest_msrs was allocated, don't allocate the memory again to avoid memory leak when init_msr_emulation is called more than once. Signed-off-by: Yin Fengwei <fengwei.yin@intel.com> Acked-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
parent
57c217bf26
commit
8b9fb3780a
|
@ -130,7 +130,9 @@ void init_msr_emulation(struct vcpu *vcpu)
|
|||
exec_vmwrite64(VMX_MSR_BITMAP_FULL, value64);
|
||||
pr_dbg("VMX_MSR_BITMAP: 0x%016llx ", value64);
|
||||
|
||||
vcpu->guest_msrs = (uint64_t *)calloc(msrs_count, sizeof(uint64_t));
|
||||
if (!vcpu->guest_msrs)
|
||||
vcpu->guest_msrs =
|
||||
(uint64_t *)calloc(msrs_count, sizeof(uint64_t));
|
||||
|
||||
ASSERT(vcpu->guest_msrs != NULL, "");
|
||||
memset(vcpu->guest_msrs, 0, msrs_count * sizeof(uint64_t));
|
||||
|
|
Loading…
Reference in New Issue