Re: [PATCH] rust: dma: require mutable reference for as_slice_mut() and write()

From: Danilo Krummrich
Date: Tue Jul 01 2025 - 08:18:20 EST


On Sat, Jun 28, 2025 at 06:49:54PM +0200, Danilo Krummrich wrote:
> Given the safety requirements of as_slice_mut() and write() taking an
> immutable reference is technically not incorrect.
>
> However, let's leverage the compiler's capabilities and require a
> mutable reference to ensure exclusive access.
>
> This also fixes a clippy warning introduced with 1.88:
>
> warning: mutable borrow from immutable input(s)
> --> rust/kernel/dma.rs:297:78
> |
> 297 | pub unsafe fn as_slice_mut(&self, offset: usize, count: usize) -> Result<&mut [T]> {
> | ^^^^^^^^
>
> Fixes: d37a39f607c4 ("rust: dma: add as_slice/write functions for CoherentAllocation")
> Signed-off-by: Danilo Krummrich <dakr@xxxxxxxxxx>

Applied to alloc-next, thanks!