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.

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)
This commit is contained in:
Mark Johnston 2025-10-17 12:55:17 +00:00
parent 56b4719076
commit 6e1f47765d

View file

@ -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;