git: 19dbf72a2701 - main - bhyve: correctly remove a memory mapping
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 29 May 2024 19:41:02 UTC
The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=19dbf72a270125621268e8b07ccc9ac99c67e7d0 commit 19dbf72a270125621268e8b07ccc9ac99c67e7d0 Author: Pierre Pronchery <pierre@freebsdfoundation.org> AuthorDate: 2024-05-29 18:00:02 +0000 Commit: Warner Losh <imp@FreeBSD.org> CommitDate: 2024-05-29 19:39:29 +0000 bhyve: correctly remove a memory mapping In a normal code path while setting up GPU passthrough, the size parameter to munmap() is wrong and its operation not checked for errors, therefore leaking resources. Reported by: Coverity Scan CID: 1519830 Sponsored by: The FreeBSD Foundation Reviewed by: imp Pull Request: https://github.com/freebsd/freebsd-src/pull/1262 --- usr.sbin/bhyve/amd64/pci_gvt-d.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/usr.sbin/bhyve/amd64/pci_gvt-d.c b/usr.sbin/bhyve/amd64/pci_gvt-d.c index f64cc5984352..dfcd6a8f68c8 100644 --- a/usr.sbin/bhyve/amd64/pci_gvt-d.c +++ b/usr.sbin/bhyve/amd64/pci_gvt-d.c @@ -220,7 +220,7 @@ gvt_d_setup_opregion(struct pci_devinst *const pi) opregion->hpa = asls; opregion->len = header->size * KB; - munmap(header, sizeof(header)); + munmap(header, sizeof(*header)); opregion->hva = mmap(NULL, opregion->len * KB, PROT_READ, MAP_SHARED, memfd, opregion->hpa);