Fix add_ref(Shared) refcounting bug.
This commit is contained in:
@@ -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
@@ -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
Reference in New Issue
Block a user