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();
}
// If the source area is writable, we need to move it one layer up as well
if (!sharedArea) {
if (writableCopy) {
// TODO: do something more useful if this fails!
if (vm_copy_on_write_area(cache,
wiredPages > 0 ? &wiredPagesReservation : NULL) < B_OK) {
panic("vm_copy_on_write_area() failed!\n");
}
// If the source area is writable, we need to move it one layer up as well.
if (!sharedArea && writableCopy) {
status_t status = vm_copy_on_write_area(cache,
wiredPages > 0 ? &wiredPagesReservation : NULL);
if (status != B_OK) {
cacheLocker.Unlock();
delete_area(targetAddressSpace, target, false);
return status;
}
}