summaryrefslogtreecommitdiff
path: root/drivers/android
diff options
context:
space:
mode:
authorTamir Duberstein <tamird@kernel.org>2026-05-26 14:39:08 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2026-07-03 12:29:38 +0200
commit7d7b2011e7554d481a6db9cf362a58508b3e009e (patch)
tree2093557b26613657bb219cda11badb50c33d6004 /drivers/android
parent32782e3115aa892f7e67cc8254808327f77217c9 (diff)
downloadlinux-7d7b2011e7554d481a6db9cf362a58508b3e009e.tar.gz
linux-7d7b2011e7554d481a6db9cf362a58508b3e009e.zip
rust: binder: enable `clippy::ptr_as_ptr` lint
In Rust 1.51.0, Clippy introduced the `ptr_as_ptr` lint [1]: > Though `as` casts between raw pointers are not terrible, > `pointer::cast` is safer because it cannot accidentally change pointer > mutability or cast the pointer to other types like `usize`. Apply the required changes and enable the lint in the Binder Rust driver -- no functional change intended. Link: https://rust-lang.github.io/rust-clippy/master/index.html#ptr_as_ptr [1] Assisted-by: Codex:gpt-5 Signed-off-by: Tamir Duberstein <tamird@kernel.org> Reviewed-by: Alice Ryhl <aliceryhl@google.com> Link: https://patch.msgid.link/20260526-binder-strict-provenance-v2-2-a41d89c29bc5@kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/android')
-rw-r--r--drivers/android/binder/defs.rs4
-rw-r--r--drivers/android/binder/page_range.rs6
-rw-r--r--drivers/android/binder/rust_binder_main.rs7
3 files changed, 6 insertions, 11 deletions
diff --git a/drivers/android/binder/defs.rs b/drivers/android/binder/defs.rs
index 33f51b4139c7..354c32c39e83 100644
--- a/drivers/android/binder/defs.rs
+++ b/drivers/android/binder/defs.rs
@@ -165,8 +165,8 @@ impl BinderTransactionDataSecctx {
pub(crate) fn tr_data(&mut self) -> &mut BinderTransactionData {
// SAFETY: Transparent wrapper is safe to transmute.
unsafe {
- &mut *(&mut self.transaction_data as *mut uapi::binder_transaction_data
- as *mut BinderTransactionData)
+ &mut *((&mut self.transaction_data as *mut uapi::binder_transaction_data)
+ .cast::<BinderTransactionData>())
}
}
}
diff --git a/drivers/android/binder/page_range.rs b/drivers/android/binder/page_range.rs
index e82a5523804f..fbb93ebb9697 100644
--- a/drivers/android/binder/page_range.rs
+++ b/drivers/android/binder/page_range.rs
@@ -571,7 +571,7 @@ impl ShrinkablePageRange {
unsafe {
self.iterate(offset, size_of::<T>(), |page, offset, to_copy| {
// SAFETY: The sum of `offset` and `to_copy` is bounded by the size of T.
- let obj_ptr = (out.as_mut_ptr() as *mut u8).add(out_offset);
+ let obj_ptr = out.as_mut_ptr().cast::<u8>().add(out_offset);
// SAFETY: The pointer points is in-bounds of the `out` variable, so it is valid.
page.read_raw(obj_ptr, offset, to_copy)?;
out_offset += to_copy;
@@ -593,7 +593,7 @@ impl ShrinkablePageRange {
unsafe {
self.iterate(offset, size_of_val(obj), |page, offset, to_copy| {
// SAFETY: The sum of `offset` and `to_copy` is bounded by the size of T.
- let obj_ptr = (obj as *const T as *const u8).add(obj_offset);
+ let obj_ptr = (obj as *const T).cast::<u8>().add(obj_offset);
// SAFETY: We have a reference to the object, so the pointer is valid.
page.write_raw(obj_ptr, offset, to_copy)?;
obj_offset += to_copy;
@@ -712,7 +712,7 @@ unsafe extern "C" fn rust_shrink_free_page(
{
// CAST: The `list_head` field is first in `PageInfo`.
- let info = item as *mut PageInfo;
+ let info = item.cast::<PageInfo>();
// SAFETY: The `range` field of `PageInfo` is immutable.
range_ptr = unsafe { (*info).range };
// SAFETY: The `range` outlives its `PageInfo` values.
diff --git a/drivers/android/binder/rust_binder_main.rs b/drivers/android/binder/rust_binder_main.rs
index d487638266e3..fa28697982d3 100644
--- a/drivers/android/binder/rust_binder_main.rs
+++ b/drivers/android/binder/rust_binder_main.rs
@@ -6,12 +6,7 @@
#![crate_name = "rust_binder"]
#![recursion_limit = "256"]
-#![allow(
- clippy::as_underscore,
- clippy::ref_as_ptr,
- clippy::ptr_as_ptr,
- clippy::cast_lossless
-)]
+#![allow(clippy::as_underscore, clippy::ref_as_ptr, clippy::cast_lossless)]
use kernel::{
bindings::{self, seq_file},