Re: [PATCH] rust: DmaFence: Add better warning through Device reference

From: Gary Guo

Date: Fri Sep 25 2026 - 06:26:39 EST


On Fri Sep 25, 2026 at 9:19 AM BST, Philipp Stanner wrote:
> FenceContext::drop() contains a warning print that warns about possible
> memory corruptions if there are forgotten fences. However, precisely
> speaking, a forgotten fence is undefined behavior.
>
> Moreover, forgotten fences hint at a severe design problem in the
> driver. In this context, the used pr_err!() does not provide very useful
> text output.
>
> Replace the warning print with a dev_warn!(). To do so, have the
> FenceContext carry a reference to a Device, protected by the already
> present lifetime.

Add a lifetime just to do this a print doesn't sound ideal. You could use
`ARef<Device>` instead?

Best,
Gary

>
> Suggested-by: Danilo Krummrich <dakr@xxxxxxxxxx>
> Signed-off-by: Philipp Stanner <phasta@xxxxxxxxxx>
> ---
> rust/kernel/dma_buf/dma_fence.rs | 25 +++++++++++++++++++------
> 1 file changed, 19 insertions(+), 6 deletions(-)
>