Using `READ_ONCE` is the correct way to read the `f_flags` field. Signed-off-by: Alice Ryhl --- rust/kernel/fs/file.rs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/rust/kernel/fs/file.rs b/rust/kernel/fs/file.rs index 23ee689bd2400565223181645157d832a836589f..6b07f08e7012f512e53743266096ce0076d29e1c 100644 --- a/rust/kernel/fs/file.rs +++ b/rust/kernel/fs/file.rs @@ -335,12 +335,8 @@ pub fn cred(&self) -> &Credential { /// The flags are a combination of the constants in [`flags`]. #[inline] pub fn flags(&self) -> u32 { - // This `read_volatile` is intended to correspond to a READ_ONCE call. - // - // SAFETY: The file is valid because the shared reference guarantees a nonzero refcount. - // - // FIXME(read_once): Replace with `read_once` when available on the Rust side. - unsafe { core::ptr::addr_of!((*self.as_ptr()).f_flags).read_volatile() } + // SAFETY: The `f_flags` field of `struct file` is readable with `READ_ONCE`. + unsafe { kernel::sync::READ_ONCE(&raw const (*self.as_ptr()).f_flags) } } } -- 2.52.0.351.gbe84eed79e-goog