Re: [PATCH] dma-buf: fix leak of ctx and dmabuf reference in dma_buf_io_ctx_create() WARN path
From: Pavel Begunkov
Date: Mon Nov 23 2026 - 08:44:09 EST
On 11/22/26 10:49, Falconet3 wrote:
Withdrawing this patch. Apologies for the noise.
The WARN_ON_ONCE() path in dma_buf_io_ctx_create() is not reachable with
in-tree code: the only in-tree implementation, nvme_init_io_ctx_locked(),
installs all of dev_ops (map/unmap/release) before it returns 0.
Right, it's a warning for the same exact reason, and cleanup considerations
for it are different as well.
And on the only path where it could ever fire — an importer violating the--
contract — freeing ctx directly is not safe: init_dma_buf_io_ctx() has
already attached ctx to the dmabuf and linked it into the importer's
tracking, so kfree() + dma_buf_put() leaves dangling pointers and turns an
unreachable leak into a potential use-after-free. Since dev_ops->release
may itself be one of the missing callbacks, the core has no safe generic
cleanup on that path.
Pavel Begunkov