Fix add_ref(Shared) refcounting bug.

This commit is contained in:
4lDO2
2024-06-23 00:35:58 +02:00
parent 7d5b2e6c21
commit 9b68d4de80
3 changed files with 8 additions and 2 deletions
+6
View File
@@ -1602,6 +1602,12 @@ impl Grant {
}
// Cannot be shared and CoW simultaneously.
Err(AddRefError::SharedToCow) => {
// The call to cow() later implicitly removes one ref, so add it here
// first, even if Shared.
if src_page_info.add_ref(RefKind::Shared) == Err(AddRefError::RcOverflow) {
return Err(Enomem);
}
// TODO: Copy in place, or use a zeroed page?
let CowResult { new_frame, old_frame } = cow(src_frame, src_page_info, rk).map_err(|_| Enomem)?;
if let Some(old_frame) = old_frame {
+1 -1
View File
@@ -643,7 +643,7 @@ pub fn init_mm(allocator: BumpAllocator<RmmA>) {
THE_ZEROED_FRAME.get().write(Some((the_frame, the_info)));
}
}
#[derive(Debug)]
#[derive(Debug, PartialEq)]
pub enum AddRefError {
CowToShared,
SharedToCow,
+1 -1
Submodule syscall updated: 5b07568677...1583e94276