Skip to content

Commit 97e000a

Browse files
drm/ttm: fix error handling in ttm_buffer_object_transfer
Unlocking the resv object was missing in the error path, additionally to that we should move over the resource only after the fence slot was reserved. Signed-off-by: Christian König <[email protected]> Reviewed-by: Matthew Brost <[email protected]> Fixes: c8d4c18 ("dma-buf/drivers: make reserving a shared slot mandatory v4") Cc: <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 2b95a7d commit 97e000a

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

drivers/gpu/drm/ttm/ttm_bo_util.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,13 @@ static int ttm_buffer_object_transfer(struct ttm_buffer_object *bo,
254254
ret = dma_resv_trylock(&fbo->base.base._resv);
255255
WARN_ON(!ret);
256256

257+
ret = dma_resv_reserve_fences(&fbo->base.base._resv, 1);
258+
if (ret) {
259+
dma_resv_unlock(&fbo->base.base._resv);
260+
kfree(fbo);
261+
return ret;
262+
}
263+
257264
if (fbo->base.resource) {
258265
ttm_resource_set_bo(fbo->base.resource, &fbo->base);
259266
bo->resource = NULL;
@@ -262,12 +269,6 @@ static int ttm_buffer_object_transfer(struct ttm_buffer_object *bo,
262269
fbo->base.bulk_move = NULL;
263270
}
264271

265-
ret = dma_resv_reserve_fences(&fbo->base.base._resv, 1);
266-
if (ret) {
267-
kfree(fbo);
268-
return ret;
269-
}
270-
271272
ttm_bo_get(bo);
272273
fbo->bo = bo;
273274

0 commit comments

Comments
 (0)