Need a pair decrement for fence's refcount if ttm_bo_add_move_fence failed?

易林 yilin at iie.ac.cn
Sun Apr 7 11:44:14 UTC 2019


Hi, all:
    when analyzing v5.1 source code, I notice that in ttm_bo_add_move_fence,
when reservation_object_reserve_shared failed and return ENOMEM, 
the fence's refcount increased without a pair decrement even after return to ttm_bo_add_move_fence's caller ttm_bo_mem_force_space:

static int ttm_bo_add_move_fence(struct ttm_buffer_object *bo,
				 struct ttm_mem_type_manager *man,
				 struct ttm_mem_reg *mem)
{
        ......
	fence = dma_fence_get(man->move);
	spin_unlock(&man->move_lock);

	if (fence) {
		reservation_object_add_shared_fence(bo->resv, fence);

		ret = reservation_object_reserve_shared(bo->resv, 1);
		if (unlikely(ret))
			return ret;

		dma_fence_put(bo->moving);
		bo->moving = fence;
	}

	return 0;
}

can this lead to the imbalance of the fence's refcount? though the ENOMEN almost won't be trigger.

Best Regards

Lin Yi


More information about the dri-devel mailing list