Date: Fri, 20 Oct 2017 21:13:20 +0000 (UTC) From: Mark Johnston <markj@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r324809 - head/sys/vm Message-ID: <201710202113.v9KLDKMA060435@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: markj Date: Fri Oct 20 21:13:19 2017 New Revision: 324809 URL: https://svnweb.freebsd.org/changeset/base/324809 Log: Free the right address range if kmem_back() fails in memguard_alloc(). MFC after: 1 week Sponsored by: Dell EMC Isilon Modified: head/sys/vm/memguard.c Modified: head/sys/vm/memguard.c ============================================================================== --- head/sys/vm/memguard.c Fri Oct 20 18:58:11 2017 (r324808) +++ head/sys/vm/memguard.c Fri Oct 20 21:13:19 2017 (r324809) @@ -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;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201710202113.v9KLDKMA060435>