[PATCH] dma-buf/sw_sync: Decrement refcount on error in sw_sync_ioctl_get_deadline()
Christian König
christian.koenig at amd.com
Mon Mar 31 12:02:44 UTC 2025
Am 31.03.25 um 11:45 schrieb Dan Carpenter:
> Call dma_fence_put(fence) before returning an error on this error path.
>
> Fixes: 70e67aaec2f4 ("dma-buf/sw_sync: Add fence deadline support")
> Signed-off-by: Dan Carpenter <dan.carpenter at linaro.org>
> ---
> drivers/dma-buf/sw_sync.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/dma-buf/sw_sync.c b/drivers/dma-buf/sw_sync.c
> index f5905d67dedb..b7615c5c6cac 100644
> --- a/drivers/dma-buf/sw_sync.c
> +++ b/drivers/dma-buf/sw_sync.c
> @@ -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;
> + }
Good catch.
I think it would be cleaner if we add an error label and then use "ret = -EINVAL; goto error;" here as well as a few lines below when ret is set to -ENOENT.
This way we can also avoid the ret = 0 in the declaration and let the compiler actually check the lifetime of the assignment.
Regards,
Christian.
>
> spin_lock_irqsave(fence->lock, flags);
> if (test_bit(SW_SYNC_HAS_DEADLINE_BIT, &fence->flags)) {
More information about the dri-devel
mailing list