On 11/12/26 11:10, Philipp Stanner wrote:
> DriverFence::drop() contains a pr_warn!() for when the fence drops
> unsignaled. This warning gets into the way of canonical teardown in
> Rust: when you drop a lock, it unlocks itself, when you drop a KBox, it
> frees itself etc. Congruently, users should be able to tear down fences
> they don't care about anymore with ECANCELED, which is already the
> default error code.

Well a dma_fence should never automatically signal when the last reference 
drops.

Leaving it unsignaled is the most defensive path we can go. That can lead to 
deadlocks but it can at least not lead to memory corruption.

Regards,
Christian.

> 
> Remove the warning.
> 
> Suggested-by: Danilo Krummrich <[email protected]>
> Signed-off-by: Philipp Stanner <[email protected]>
> ---
>  rust/kernel/dma_buf/dma_fence.rs | 1 -
>  1 file changed, 1 deletion(-)
> 
> diff --git a/rust/kernel/dma_buf/dma_fence.rs 
> b/rust/kernel/dma_buf/dma_fence.rs
> index a1d851656562..2c8001cb9a59 100644
> --- a/rust/kernel/dma_buf/dma_fence.rs
> +++ b/rust/kernel/dma_buf/dma_fence.rs
> @@ -942,7 +942,6 @@ fn drop(&mut self) {
>          // SAFETY: `guard` is valid until the `call_rcu()` below.
>          let signaled: bool = unsafe { 
> bindings::dma_fence_test_signaled_flag(guard.as_raw()) };
>          if !signaled {
> -            pr_err!("DriverFence drops unsignaled. Danger of memory 
> corruption!\n");
>              // SAFETY: `guard` is valid until the `call_rcu()` below. The 
> fence
>              // must not have been signaled yet, which we check directly 
> above.
>              unsafe { bindings::dma_fence_set_error(guard.as_raw(), 
> ECANCELED.to_errno()) };

Reply via email to