We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 3e8a61a commit d4b4cffCopy full SHA for d4b4cff
1 file changed
rust/kernel/io_buffer.rs
@@ -4,6 +4,7 @@
4
5
//! Buffers used in IO.
6
7
+use crate::alloc::{flags::*, vec_ext::VecExt};
8
use crate::error::Result;
9
use alloc::vec::Vec;
10
use core::mem::{size_of, MaybeUninit};
@@ -31,8 +32,11 @@ pub trait IoBufferReader {
31
32
///
33
/// Returns `EFAULT` if the address does not currently point to mapped, readable memory.
34
fn read_all(&mut self) -> Result<Vec<u8>> {
- let mut data = Vec::<u8>::new();
35
- data.try_resize(self.len(), 0)?;
+ let mut data = Vec::<u8>::with_capacity(self.len(), GFP_KERNEL)?;
36
+ // FIXME? data.resize(self.len(), 0);
37
+ for _ in 0..self.len() {
38
+ data.push(0, GFP_KERNEL)?
39
+ }
40
41
// SAFETY: The output buffer is valid as we just allocated it.
42
unsafe { self.read_raw(data.as_mut_ptr(), data.len())? };
0 commit comments