mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-06-24 14:33:38 +00:00
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);
|
exec_vmwrite64(VMX_MSR_BITMAP_FULL, value64);
|
||||||
pr_dbg("VMX_MSR_BITMAP: 0x%016llx ", 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, "");
|
ASSERT(vcpu->guest_msrs != NULL, "");
|
||||||
memset(vcpu->guest_msrs, 0, msrs_count * sizeof(uint64_t));
|
memset(vcpu->guest_msrs, 0, msrs_count * sizeof(uint64_t));
|
||||||
|
Loading…
Reference in New Issue
Block a user