Skip to contentSkip to conversation

dma-buf/sw_sync: Fix refcount leak in sw_sync_ioctl_get_deadline

PATCH New Miaoqian Lin 1 participant 1 message Mar 18, 2025

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 dma-buf/sw_sync: Fix refcount leak in sw_sync_ioctl_get_deadline

Fix reference count leak in by adding dma_fence_put() when dma_fence_to_sync_pt() fails after the call to sync_file_get_fence().

Fixes 70e67aaec2f4 ("dma-buf/sw_sync: Add fence deadline support")
---
 drivers/dma-buf/sw_sync.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/dma-buf/sw_sync.c +3 -1
index f5905d67dedb..b7615c5c6cac 100644
@@ -438,8 +438,10 @@ static int sw_sync_ioctl_get_deadline(struct sync_timeline *obj, unsigned long a
 		return -EINVAL;
 
 	pt = dma_fence_to_sync_pt(fence);
-	if (!pt)
+	if (!pt) {
+		dma_fence_put(fence);
 		return -EINVAL;
+	}
 
 	spin_lock_irqsave(fence->lock, flags);
 	if (test_bit(SW_SYNC_HAS_DEADLINE_BIT, &fence->flags)) {
Signature · 1 line
2.39.5 (Apple Git-154)