[PATCH] rust: kernel: fix lifetime of copy_from_iter_raw

From: Marwan Mohamed Zein

Date: Fri Nov 13 2026 - 21:45:57 EST


From: martell0x1 <marawanzein222@xxxxxxxxx>

The returned slice is derived from `out`, but lifetime elision
ties it to `self` because this is a method. Explicitly bind the
return lifetime to `out` so the returned slice cannot outlive
its backing buffer.

Reported-by: spidermana <xuyiwen14@xxxxxxxxx>
Closes: https://github.com/Rust-for-Linux/linux/issues/1265
Signed-off-by: martell0x1 <marawanzein222@xxxxxxxxx>
---
rust/kernel/iov.rs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/rust/kernel/iov.rs b/rust/kernel/iov.rs
index 43bae8923..8caf04518 100644
--- a/rust/kernel/iov.rs
+++ b/rust/kernel/iov.rs
@@ -161,7 +161,7 @@ pub fn copy_from_iter_vec<A: Allocator>(
///
/// This will never write uninitialized bytes to the provided buffer.
#[inline]
- pub fn copy_from_iter_raw(&mut self, out: &mut [MaybeUninit<u8>]) -> &mut [u8] {
+ pub fn copy_from_iter_raw<'a>(&mut self, out: &'a mut [MaybeUninit<u8>]) -> &'a mut [u8] {
let capacity = out.len();
let out = out.as_mut_ptr().cast::<u8>();


base-commit: ee83899302a0457a3ba47464a13e8682bd7ba27d
--
2.47.3