From nobody Fri Nov 18 18:26:53 2022 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4NDQH60w01z4d7wk; Fri, 18 Nov 2022 18:26:57 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4NDQH53RFVz4JZF; Fri, 18 Nov 2022 18:26:57 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1668796017; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=ImchPhu9tUOqV+5S6sPE4wUtZpB4IhBNFAvDHcYOweI=; b=LC0P7w81tpv5xa5e/iPwnoJZntsRgq6sRr+67qby5bXIvNHwWf0/kAlZHbuxdv7DKjwlhu 2d8faZGl/GSN8fbYiC0PKIsyAwSOOewQl6S25auGWFyoQ+fchjlwTS5rsQI73bgMHuOhid /z3SLnr1ofojDgRxaFIJOIKDyCz2vapsgXqXCYL9Y+JUO9OAg1qu3U6wGkpfHpY27yeWFy oAQ7UBlmBEs5zbwEvZgscCUv4skMUvGWo9UVWbeiylo0oGLVvRI3inrP7ZHEmZXgI2ztoz t2fYLOh74hNQ1XCa571x36arjrS42tmIV6AedhwGRgRN76I5/iaDfd4/2aDsRg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1668796017; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=ImchPhu9tUOqV+5S6sPE4wUtZpB4IhBNFAvDHcYOweI=; b=eewzLQuRepk2D552kIR+EhF7WqmFobo68TiKwamqNoiCFrdf6C6NPH43wgjk0HxdTVGTg7 W+R+vXE+ib7VYH4WmcbeMhTmAaO1CtgIUNdZ1H+PKAYtmJMt6Ed284c3YcyAkT4ryEjyEd rGcMl4pBVlOnPXjRW4/eSSW9rDEWHNaOvTHPiiygHXV6pXyHjcmJqcUcBtnEhr5JdmDl6i SVuBqCjBk0xi3IazRXkoUvjMA3f+0UTYwXTa3DYz2stASJaow9GnFK9q/am2MTo64p7BUl j6Pa8y/rCAmzTYW5Kz5TEN21V3gh8u4mVgBK1F6BM6KjHcOOWqXJRD78AFkVag== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1668796017; a=rsa-sha256; cv=none; b=xVgmrFLCXukFkTS/ZqOIRnf07nhaI4malxqffVAL5kZpCpREshNDPnxgUjYtkG7HbJUlwj kNbjj7wCiizQOrfhRwIN1B2k3BHN4dz8HBKcZei2kaHRDGB5jMwYjDjkoNiHyCutsFiIdl NtuXmvTAMVxA82VjIZoWmBNq9NTVwno3FyPwuRUok4+O2uYrguq7+w36t8xwP/GZfGN9Ab TquyAwf+JvmeAiQkn2an1L7DlSYy5hhjn5ct1md/CI25z066u/mR7oQ1a7U4+qS4muKdMx rDzmpKCfSDfWolDH5jp0OWHlJU7JqRhcrMNNBwM2knlyRIm1m24osbb9ORAzOQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4NDQH21lXNzFW4; Fri, 18 Nov 2022 18:26:53 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 2AIIQrAN030729; Fri, 18 Nov 2022 18:26:53 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 2AIIQr7S030728; Fri, 18 Nov 2022 18:26:53 GMT (envelope-from git) Date: Fri, 18 Nov 2022 18:26:53 GMT Message-Id: <202211181826.2AIIQr7S030728@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: John Baldwin Subject: git: 223de44c9365 - main - vmm devmem_mmap_single: Bump object reference under memsegs lock. List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jhb X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 223de44c93659457e05036dec25b0af610a773a6 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=223de44c93659457e05036dec25b0af610a773a6 commit 223de44c93659457e05036dec25b0af610a773a6 Author: John Baldwin AuthorDate: 2022-11-18 18:04:58 +0000 Commit: John Baldwin CommitDate: 2022-11-18 18:25:38 +0000 vmm devmem_mmap_single: Bump object reference under memsegs lock. Reported by: markj Reviewed by: corvink, markj Differential Revision: https://reviews.freebsd.org/D37273 --- sys/amd64/vmm/vmm_dev.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/sys/amd64/vmm/vmm_dev.c b/sys/amd64/vmm/vmm_dev.c index 1b8b1e6d388f..a7c12da68701 100644 --- a/sys/amd64/vmm/vmm_dev.c +++ b/sys/amd64/vmm/vmm_dev.c @@ -1262,15 +1262,13 @@ devmem_mmap_single(struct cdev *cdev, vm_ooffset_t *offset, vm_size_t len, KASSERT(error == 0 && !sysmem && *objp != NULL, ("%s: invalid devmem segment %d", __func__, dsc->segid)); + if (seglen >= last) + vm_object_reference(*objp); + else + error = EINVAL; vm_unlock_memsegs(dsc->sc->vm); - - if (seglen >= last) { - vm_object_reference(*objp); - return (0); - } else { - return (EINVAL); - } + return (error); } static struct cdevsw devmemsw = {