vmm: don't free unallocated memory
If vmx or svm is disabled in BIOS or the device isn't supported by vmm,
modinit won't allocate these state save areas. As kmem_free panics when
passing a NULL pointer to it, loading the vmm kernel module causes a
panic too.
PR: 271251
Reviewed by: markj
Fixes: 74ac712f72
("vmm: Dynamically allocate a couple of per-CPU state save areas")
MFC after: 1 week
Sponsored by: Beckhoff Automation GmbH & Co. KG
Differential Revision: https://reviews.freebsd.org/D39974
This commit is contained in:
parent
66659955da
commit
b10e100d16
@ -166,7 +166,10 @@ svm_modcleanup(void)
|
||||
{
|
||||
|
||||
smp_rendezvous(NULL, svm_disable, NULL, NULL);
|
||||
kmem_free(hsave, (mp_maxid + 1) * PAGE_SIZE);
|
||||
|
||||
if (hsave != NULL)
|
||||
kmem_free(hsave, (mp_maxid + 1) * PAGE_SIZE);
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
@ -619,7 +619,9 @@ vmx_modcleanup(void)
|
||||
nmi_flush_l1d_sw = 0;
|
||||
|
||||
smp_rendezvous(NULL, vmx_disable, NULL, NULL);
|
||||
kmem_free(vmxon_region, (mp_maxid + 1) * PAGE_SIZE);
|
||||
|
||||
if (vmxon_region != NULL)
|
||||
kmem_free(vmxon_region, (mp_maxid + 1) * PAGE_SIZE);
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user