git: drm: Balance dma-buf file references on get and fd export

Aaron LI aly at crater.dragonflybsd.org
Mon Oct 5 06:32:13 PDT 2026


commit ea80485f6cd5e7b7c5733dc15f0afebf3cd286aa
Author: David Bidner <david at crap.solutions>
Date:   Thu Oct 1 06:03:41 2026 +0200

    drm: Balance dma-buf file references on get and fd export
    
    dma_buf_get() drops its lookup reference before returning, but its callers
    release the returned buffer with dma_buf_put(). Repeated imports can
    therefore consume references owned by the descriptor and PRIME caches.
    Retain an independent file reference before dropping the lookup reference.
    
    dma_buf_fd() transfers the caller's reference to the new descriptor.
    fsetfd() acquires another reference, so drop the caller's reference after
    successful installation. Keep it on allocation failure.
    
    FreeBSD's dma-buf implementation follows the same ownership rules: retain
    the fget() reference on lookup and drop the extra reference taken by
    finstall() after successful descriptor installation.
    
    The comments were extracted from the patch bundle by servik and dillon:
    https://apollo.backplane.com/DFlyMisc/drm98.patch
    
    Reference: https://github.com/freebsd/drm-kmod/blob/f252a30f27d157d9c763cd408850775096a6263f/drivers/dma-buf/dma-buf.c#L498-L544
    Bug: https://bugs.dragonflybsd.org/issues/3428

Summary of changes:
 sys/dev/drm/linux_dma-buf.c | 6 ++++++
 1 file changed, 6 insertions(+)

http://gitweb.dragonflybsd.org/dragonfly.git/commitdiff/ea80485f6cd5e7b7c5733dc15f0afebf3cd286aa


-- 
DragonFly BSD source repository


More information about the Commits mailing list