From owner-svn-src-stable@freebsd.org Fri Oct 27 14:22:57 2017 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 7DA1AE466E4; Fri, 27 Oct 2017 14:22:57 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4AF436710C; Fri, 27 Oct 2017 14:22:57 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v9REMuvf093618; Fri, 27 Oct 2017 14:22:56 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v9REMuTF093617; Fri, 27 Oct 2017 14:22:56 GMT (envelope-from markj@FreeBSD.org) Message-Id: <201710271422.v9REMuTF093617@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Fri, 27 Oct 2017 14:22:56 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r325036 - stable/11/sys/vm X-SVN-Group: stable-11 X-SVN-Commit-Author: markj X-SVN-Commit-Paths: stable/11/sys/vm X-SVN-Commit-Revision: 325036 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Oct 2017 14:22:57 -0000 Author: markj Date: Fri Oct 27 14:22:56 2017 New Revision: 325036 URL: https://svnweb.freebsd.org/changeset/base/325036 Log: MFC r324809: Free the right address range if kmem_back() fails in memguard_alloc(). Modified: stable/11/sys/vm/memguard.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/vm/memguard.c ============================================================================== --- stable/11/sys/vm/memguard.c Fri Oct 27 12:37:22 2017 (r325035) +++ stable/11/sys/vm/memguard.c Fri Oct 27 14:22:56 2017 (r325036) @@ -283,7 +283,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; @@ -327,7 +327,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 @@ -342,11 +342,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;