kernel/vm: Handle vm_copy_on_write_area failing properly.

Just delete the newly-created area and return the error.

Fixes #13455.
This commit is contained in:
Augustin Cavalier
2024-12-13 18:08:22 -05:00
parent 5cfac6e80f
commit 2acb67eef0
+8 -8
View File
@@ -3004,14 +3004,14 @@ vm_copy_area(team_id team, const char* name, void** _address,
cache->AcquireRefLocked(); cache->AcquireRefLocked();
} }
// If the source area is writable, we need to move it one layer up as well // If the source area is writable, we need to move it one layer up as well.
if (!sharedArea) { if (!sharedArea && writableCopy) {
if (writableCopy) { status_t status = vm_copy_on_write_area(cache,
// TODO: do something more useful if this fails! wiredPages > 0 ? &wiredPagesReservation : NULL);
if (vm_copy_on_write_area(cache, if (status != B_OK) {
wiredPages > 0 ? &wiredPagesReservation : NULL) < B_OK) { cacheLocker.Unlock();
panic("vm_copy_on_write_area() failed!\n"); delete_area(targetAddressSpace, target, false);
} return status;
} }
} }