Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues: - [High] Resource leak of I/O mapped virtual memory in `IoMem::ioremap` upon `MmioRaw::new_region` failure. -- commit 341339f8ea263586994f368a12f84cd531475a2a Author: Gary Guo <[email protected]> Update MmioRaw to use the dynamic-sized type Region<SIZE> instead of representing compile-time known minimum sizes directly. Implement Clone, Copy, Send, and Sync manually due to raw pointer usage. > diff --git a/rust/kernel/io/mem.rs b/rust/kernel/io/mem.rs > index fc2a3e24f8d5..9e15bc8fde78 100644 > --- a/rust/kernel/io/mem.rs > +++ b/rust/kernel/io/mem.rs [ ... ] > @@ -264,8 +264,7 @@ fn ioremap(dev: &'a Device<Bound>, resource: &Resource) > -> Result<Self> { > return Err(ENOMEM); > } > > - let io = MmioRaw::new(addr as usize, size)?; > - > + let io = MmioRaw::new_region(addr as usize, size)?; [Severity: High] This is a pre-existing issue, but does this early return via the ? operator leak the mapped I/O virtual memory in IoMem::ioremap()? If MmioRaw::new_region() fails (for example, if the device's hardware size is smaller than the statically requested SIZE), the ? operator causes an early return with an error. Because the IoMem structure is not yet fully constructed, its Drop implementation is never invoked. This means bindings::iounmap is bypassed, abandoning the raw addr pointer and leading to an unrecoverable leak of vmalloc space. > Ok(IoMem { dev, io }) > } -- Sashiko AI review ยท https://sashiko.dev/#/patchset/[email protected]?part=5
