Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions drivers/android/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,7 @@ impl Process {
pub(crate) fn buffer_get(&self, ptr: usize) -> Option<Allocation> {
let mut inner = self.inner.lock();
let mapping = inner.mapping.as_mut()?;
let offset = ptr - mapping.address;
let offset = ptr.checked_sub(mapping.address)?;
let (size, odata) = mapping.alloc.reserve_existing(offset).ok()?;
let mut alloc = Allocation::new(self, offset, size, ptr, mapping.pages.clone());
if let Some(data) = odata {
Expand All @@ -557,12 +557,17 @@ impl Process {
pub(crate) fn buffer_raw_free(&self, ptr: usize) {
let mut inner = self.inner.lock();
if let Some(ref mut mapping) = &mut inner.mapping {
if mapping
.alloc
.reservation_abort(ptr - mapping.address)
.is_err()
if ptr < mapping.address
|| mapping
.alloc
.reservation_abort(ptr - mapping.address)
.is_err()
{
pr_warn!("Offset {} failed to free\n", ptr - mapping.address);
pr_warn!(
"Pointer {:x} failed to free, base = {:x}\n",
ptr,
mapping.address
);
}
}
}
Expand Down