git: 81a98c3a12e4 - releng/15.0 - netmap: Fix error handling in nm_os_extmem_create()
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 30 Oct 2025 04:23:36 UTC
The branch releng/15.0 has been updated by cperciva:
URL: https://cgit.FreeBSD.org/src/commit/?id=81a98c3a12e462243fffbe3332364bcbb4b499dc
commit 81a98c3a12e462243fffbe3332364bcbb4b499dc
Author: Mark Johnston <markj@FreeBSD.org>
AuthorDate: 2025-10-17 12:55:17 +0000
Commit: Colin Percival <cperciva@FreeBSD.org>
CommitDate: 2025-10-30 04:22:28 +0000
netmap: Fix error handling in nm_os_extmem_create()
We bump the object reference count prior to mapping it into the kernel
map, at which point the vm_map_entry owns the reference. Then, if
vm_map_wire() fails, vm_map_remove() will release the reference, so we
should avoid decrementing it in the error path.
Approved by: re (cperciva)
Reported by: Ilja van Sprundel <ivansprundel@ioactive.com>
Reviewed by: vmaffione
MFC after: 1 week
Differential Revision: https://reviews.freebsd.org/D53066
(cherry picked from commit dfc1041c08ba32f24b8050b4d635a0bbbfd9b767)
(cherry picked from commit 6e1f47765d3cf425b2b0e56d79f38b94aa107e71)
---
sys/dev/netmap/netmap_freebsd.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/sys/dev/netmap/netmap_freebsd.c b/sys/dev/netmap/netmap_freebsd.c
index 8cc543d54c2e..ac267a66d669 100644
--- a/sys/dev/netmap/netmap_freebsd.c
+++ b/sys/dev/netmap/netmap_freebsd.c
@@ -738,6 +738,7 @@ nm_os_extmem_create(unsigned long p, struct nmreq_pools_info *pi, int *perror)
out_rem:
vm_map_remove(kernel_map, e->kva, e->kva + e->size);
+ e->obj = NULL; /* reference consumed by vm_map_remove() */
out_rel:
vm_object_deallocate(e->obj);
e->obj = NULL;