vm: Fix error handling in vm_thread_stack_back()

vm_object_page_remove() wants to busy the page, but that won't work
here.  (Kernel stack pages are always busy.)

Make the error handling path look more like vm_thread_stack_dispose().

Reported by:	pho
Reviewed by:	kib, bnovkov
Fixes:	7a79d06697 ("vm: improve kstack_object pindex calculation to avoid pindex holes")
Differential Revision:	https://reviews.freebsd.org/D45019
This commit is contained in:
Mark Johnston 2024-04-29 12:22:36 -04:00
parent 9b30b96c1f
commit 661a83f9bf

View file

@ -630,7 +630,11 @@ vm_thread_stack_back(vm_offset_t ks, vm_page_t ma[], int npages, int req_class,
return (0);
cleanup:
vm_object_page_remove(obj, pindex, pindex + n, 0);
for (int i = 0; i < n; i++) {
m = ma[i];
(void)vm_page_unwire_noq(m);
vm_page_free(m);
}
VM_OBJECT_WUNLOCK(obj);
return (ENOMEM);