From 19b143b7bc3865fed8c8b09156b85d8c41c32d6b Mon Sep 17 00:00:00 2001 From: Faith Ekstrand Date: Thu, 9 May 2024 14:33:16 -0500 Subject: [PATCH] nouveau/winsys: Take a reference to BOs found in the cache Fixes: c370260a8f15 ("nouveau/winsys: Add dma-buf import support") Reviewed-by: Dave Airlie Part-of: --- src/nouveau/winsys/nouveau_bo.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/nouveau/winsys/nouveau_bo.c b/src/nouveau/winsys/nouveau_bo.c index e8240f9a271..71fd46a1538 100644 --- a/src/nouveau/winsys/nouveau_bo.c +++ b/src/nouveau/winsys/nouveau_bo.c @@ -269,8 +269,11 @@ nouveau_ws_bo_from_dma_buf_locked(struct nouveau_ws_device *dev, int fd) struct hash_entry *entry = _mesa_hash_table_search(dev->bos, (void *)(uintptr_t)handle); - if (entry != NULL) - return entry->data; + if (entry != NULL) { + struct nouveau_ws_bo *bo = entry->data; + nouveau_ws_bo_ref(bo); + return bo; + } /* * If we got here, no BO exists for the retrieved handle. If we error