lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20260130-coherent-array-v1-5-bcd672dacc70@nvidia.com>
Date: Fri, 30 Jan 2026 17:34:08 +0900
From: Eliot Courtney <ecourtney@...dia.com>
To: Danilo Krummrich <dakr@...nel.org>, 
 Alexandre Courbot <acourbot@...dia.com>, Alice Ryhl <aliceryhl@...gle.com>, 
 David Airlie <airlied@...il.com>, Simona Vetter <simona@...ll.ch>, 
 Abdiel Janulgue <abdiel.janulgue@...il.com>, 
 Daniel Almeida <daniel.almeida@...labora.com>, 
 Robin Murphy <robin.murphy@....com>, 
 Andreas Hindborg <a.hindborg@...nel.org>, Miguel Ojeda <ojeda@...nel.org>, 
 Boqun Feng <boqun.feng@...il.com>, Gary Guo <gary@...yguo.net>, 
 Björn Roy Baron <bjorn3_gh@...tonmail.com>, 
 Benno Lossin <lossin@...nel.org>, Trevor Gross <tmgross@...ch.edu>
Cc: nouveau@...ts.freedesktop.org, dri-devel@...ts.freedesktop.org, 
 linux-kernel@...r.kernel.org, driver-core@...ts.linux.dev, 
 rust-for-linux@...r.kernel.org, Eliot Courtney <ecourtney@...dia.com>
Subject: [PATCH 5/9] rust: dma: rename try_item_from_index to try_ptr_at

This function returns a pointer, so rename it to be clearer about what
it is getting.

Signed-off-by: Eliot Courtney <ecourtney@...dia.com>
---
 rust/kernel/dma.rs | 28 ++++++++++++++--------------
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/rust/kernel/dma.rs b/rust/kernel/dma.rs
index 03fc001eb983..e4bca7a18ac1 100644
--- a/rust/kernel/dma.rs
+++ b/rust/kernel/dma.rs
@@ -559,7 +559,7 @@ pub unsafe fn try_write(&mut self, src: &[T], offset: usize) -> Result {
     /// Public but hidden since it should only be used from [`try_dma_read`] and [`try_dma_write`]
     /// macros.
     #[doc(hidden)]
-    pub fn try_item_from_index(&self, offset: usize) -> Result<*mut T> {
+    pub fn try_ptr_at(&self, offset: usize) -> Result<*mut T> {
         if offset >= self.count {
             return Err(EINVAL);
         }
@@ -863,12 +863,12 @@ unsafe impl<T: AsBytes + FromBytes + Send, Size: AllocationSize> Send
 macro_rules! try_dma_read {
     ($dma:expr, $idx:expr, $($field:tt)*) => {{
         (|| -> ::core::result::Result<_, $crate::error::Error> {
-            let item = $crate::dma::CoherentAllocation::try_item_from_index(&$dma, $idx)?;
-            // SAFETY: `try_item_from_index` ensures that `item` is always a valid pointer
-            // and can be dereferenced. The compiler also further validates the expression
-            // on whether `field` is a member of `item` when expanded by the macro.
+            let ptr = $crate::dma::CoherentAllocation::try_ptr_at(&$dma, $idx)?;
+            // SAFETY: `try_ptr_at` ensures that `ptr` is always a valid pointer and can be
+            // dereferenced. The compiler also further validates the expression on whether `field`
+            // is a member of `ptr` when expanded by the macro.
             unsafe {
-                let ptr_field = ::core::ptr::addr_of!((*item) $($field)*);
+                let ptr_field = ::core::ptr::addr_of!((*ptr) $($field)*);
                 ::core::result::Result::Ok(
                     $crate::dma::CoherentAllocation::field_read(&$dma, ptr_field)
                 )
@@ -904,20 +904,20 @@ macro_rules! try_dma_read {
 macro_rules! try_dma_write {
     ($dma:expr, $idx:expr, = $val:expr) => {
         (|| -> ::core::result::Result<_, $crate::error::Error> {
-            let item = $crate::dma::CoherentAllocation::try_item_from_index(&$dma, $idx)?;
-            // SAFETY: `try_item_from_index` ensures that `item` is always a valid item.
-            unsafe { $crate::dma::CoherentAllocation::field_write(&$dma, item, $val) }
+            let ptr = $crate::dma::CoherentAllocation::try_ptr_at(&$dma, $idx)?;
+            // SAFETY: `try_ptr_at` ensures that `ptr` is always a valid ptr.
+            unsafe { $crate::dma::CoherentAllocation::field_write(&$dma, ptr, $val) }
             ::core::result::Result::Ok(())
         })()
     };
     ($dma:expr, $idx:expr, $(.$field:ident)* = $val:expr) => {
         (|| -> ::core::result::Result<_, $crate::error::Error> {
-            let item = $crate::dma::CoherentAllocation::try_item_from_index(&$dma, $idx)?;
-            // SAFETY: `try_item_from_index` ensures that `item` is always a valid pointer
-            // and can be dereferenced. The compiler also further validates the expression
-            // on whether `field` is a member of `item` when expanded by the macro.
+            let ptr = $crate::dma::CoherentAllocation::try_ptr_at(&$dma, $idx)?;
+            // SAFETY: `try_ptr_at` ensures that `ptr` is always a valid pointer and can be
+            // dereferenced. The compiler also further validates the expression on whether `field`
+            // is a member of `ptr` when expanded by the macro.
             unsafe {
-                let ptr_field = ::core::ptr::addr_of_mut!((*item) $(.$field)*);
+                let ptr_field = ::core::ptr::addr_of_mut!((*ptr) $(.$field)*);
                 $crate::dma::CoherentAllocation::field_write(&$dma, ptr_field, $val)
             }
             ::core::result::Result::Ok(())

-- 
2.52.0


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ