diff --git a/drivers/android/binder/node.rs b/drivers/android/binder/node.rs index 18cc45ce6eeb..4d6a649f3bfa 100644 --- a/drivers/android/binder/node.rs +++ b/drivers/android/binder/node.rs @@ -874,6 +874,10 @@ pub(crate) fn update(&mut self, inc: bool, strong: bool) -> bool { } *count += 1; } else { + if *count == 0 { + pr_warn!("pid {} performed invalid decrement on ref\n", kernel::current!().pid()); + return false; + } *count -= 1; if *count == 0 { self.node.update_refcount(false, *node_count, strong); diff --git a/drivers/android/binder/process.rs b/drivers/android/binder/process.rs index 5f64c59bc3fe..c1a735915637 100644 --- a/drivers/android/binder/process.rs +++ b/drivers/android/binder/process.rs @@ -926,6 +926,8 @@ pub(crate) fn update_ref( refs.by_handle.remove(&handle); refs.by_node.remove(&id); } + } else { + pr_warn!("{}: no such ref {handle}\n", kernel::current!().pid()); } Ok(()) }