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]
Date: Mon, 20 May 2024 17:24:31 +0200
From: Danilo Krummrich <dakr@...hat.com>
To: Miguel Ojeda <ojeda@...nel.org>
Cc: Wedson Almeida Filho <wedsonaf@...il.com>,
	Alex Gaynor <alex.gaynor@...il.com>,
	Boqun Feng <boqun.feng@...il.com>, Gary Guo <gary@...yguo.net>,
	Björn Roy Baron <bjorn3_gh@...tonmail.com>,
	Benno Lossin <benno.lossin@...ton.me>,
	Andreas Hindborg <a.hindborg@...sung.com>,
	Alice Ryhl <aliceryhl@...gle.com>, rust-for-linux@...r.kernel.org,
	linux-kernel@...r.kernel.org, patches@...ts.linux.dev
Subject: Re: [PATCH] rust: avoid unused import warning in `rusttest`

On Sun, May 19, 2024 at 11:07:35PM +0200, Miguel Ojeda wrote:
> When compiling for the `rusttest` target, the `core::ptr` import is
> unused since its only use happens in the `reserve()` method which is
> not compiled in that target:
> 
>     warning: unused import: `core::ptr`
>     --> rust/kernel/alloc/vec_ext.rs:7:5
>       |
>     7 | use core::ptr;
>       |     ^^^^^^^^^
>       |
>       = note: `#[warn(unused_imports)]` on by default
> 
> Thus clean it.
> 
> Fixes: 97ab3e8eec0c ("rust: alloc: fix dangling pointer in VecExt<T>::reserve()")
> Signed-off-by: Miguel Ojeda <ojeda@...nel.org>

Reviewed-by: Danilo Krummrich <dakr@...hat.com>

> ---
>  rust/kernel/alloc/vec_ext.rs | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/rust/kernel/alloc/vec_ext.rs b/rust/kernel/alloc/vec_ext.rs
> index e9a81052728a..1297a4be32e8 100644
> --- a/rust/kernel/alloc/vec_ext.rs
> +++ b/rust/kernel/alloc/vec_ext.rs
> @@ -4,7 +4,6 @@
>  
>  use super::{AllocError, Flags};
>  use alloc::vec::Vec;
> -use core::ptr;
>  
>  /// Extensions to [`Vec`].
>  pub trait VecExt<T>: Sized {
> @@ -141,7 +140,11 @@ fn reserve(&mut self, additional: usize, flags: Flags) -> Result<(), AllocError>
>          // `krealloc_aligned`. A `Vec<T>`'s `ptr` value is not guaranteed to be NULL and might be
>          // dangling after being created with `Vec::new`. Instead, we can rely on `Vec<T>`'s capacity
>          // to be zero if no memory has been allocated yet.
> -        let ptr = if cap == 0 { ptr::null_mut() } else { old_ptr };
> +        let ptr = if cap == 0 {
> +            core::ptr::null_mut()
> +        } else {
> +            old_ptr
> +        };
>  
>          // SAFETY: `ptr` is valid because it's either NULL or comes from a previous call to
>          // `krealloc_aligned`. We also verified that the type is not a ZST.
> 
> base-commit: 97ab3e8eec0ce79d9e265e6c9e4c480492180409
> -- 
> 2.45.1
> 


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ