git: c4469e134e04 - stable/13 - vmm devmem_mmap_single: Bump object reference under memsegs lock.
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 26 Jan 2023 22:12:10 UTC
The branch stable/13 has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=c4469e134e0479c03aedc3bf4e85221f29b1c26b commit c4469e134e0479c03aedc3bf4e85221f29b1c26b Author: John Baldwin <jhb@FreeBSD.org> AuthorDate: 2022-11-18 18:04:58 +0000 Commit: John Baldwin <jhb@FreeBSD.org> CommitDate: 2023-01-26 22:05:46 +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 (cherry picked from commit 223de44c93659457e05036dec25b0af610a773a6) --- 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 571e287dc4b6..90b0b6b45f26 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 = {