mirror of
https://github.com/freebsd/freebsd-src
synced 2024-09-06 17:18:32 +00:00
Free the right address range if kmem_back() fails in memguard_alloc().
MFC after: 1 week Sponsored by: Dell EMC Isilon
This commit is contained in:
parent
e66167764a
commit
eadbeae5e7
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=324809
|
@ -284,7 +284,7 @@ v2sizev(vm_offset_t va)
|
|||
void *
|
||||
memguard_alloc(unsigned long req_size, int flags)
|
||||
{
|
||||
vm_offset_t addr;
|
||||
vm_offset_t addr, origaddr;
|
||||
u_long size_p, size_v;
|
||||
int do_guard, rv;
|
||||
|
||||
|
@ -328,7 +328,7 @@ memguard_alloc(unsigned long req_size, int flags)
|
|||
for (;;) {
|
||||
if (vmem_xalloc(memguard_arena, size_v, 0, 0, 0,
|
||||
memguard_cursor, VMEM_ADDR_MAX,
|
||||
M_BESTFIT | M_NOWAIT, &addr) == 0)
|
||||
M_BESTFIT | M_NOWAIT, &origaddr) == 0)
|
||||
break;
|
||||
/*
|
||||
* The map has no space. This may be due to
|
||||
|
@ -343,11 +343,12 @@ memguard_alloc(unsigned long req_size, int flags)
|
|||
memguard_wrap++;
|
||||
memguard_cursor = memguard_base;
|
||||
}
|
||||
addr = origaddr;
|
||||
if (do_guard)
|
||||
addr += PAGE_SIZE;
|
||||
rv = kmem_back(kmem_object, addr, size_p, flags);
|
||||
if (rv != KERN_SUCCESS) {
|
||||
vmem_xfree(memguard_arena, addr, size_v);
|
||||
vmem_xfree(memguard_arena, origaddr, size_v);
|
||||
memguard_fail_pgs++;
|
||||
addr = (vm_offset_t)NULL;
|
||||
goto out;
|
||||
|
|
Loading…
Reference in a new issue