aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaarten Lankhorst <[email protected]>2023-07-25 17:12:39 +0200
committerRodrigo Vivi <[email protected]>2023-12-21 11:39:17 -0500
commit2a368a09ae1c3f7aebe6210927a1335186d3c6f7 (patch)
tree73dea1d76b35788424bc5e3be69deb3fd65f9373
parentf82686ef74b96a51ba6c38f3ce119ba7f7995210 (diff)
drm/xe: Fix error paths of __xe_bo_create_locked
ttm_bo_init_reserved() calls the destroy() callback if it fails. Because of this, __xe_bo_create_locked is required to be responsible for freeing the bo even when it's passed in as argument. Additionally, if the placement check fails, the bo was kept alive. Fix it too. Reported-by: Oded Gabbay <[email protected]> Signed-off-by: Maarten Lankhorst <[email protected]> Reviewed-by: Matthew Brost <[email protected]> Signed-off-by: Rodrigo Vivi <[email protected]>
-rw-r--r--drivers/gpu/drm/xe/xe_bo.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/drivers/gpu/drm/xe/xe_bo.c b/drivers/gpu/drm/xe/xe_bo.c
index cf0faaefd03d..a12613002766 100644
--- a/drivers/gpu/drm/xe/xe_bo.c
+++ b/drivers/gpu/drm/xe/xe_bo.c
@@ -1200,8 +1200,10 @@ struct xe_bo *__xe_bo_create_locked(struct xe_device *xe, struct xe_bo *bo,
/* Only kernel objects should set GT */
XE_WARN_ON(tile && type != ttm_bo_type_kernel);
- if (XE_WARN_ON(!size))
+ if (XE_WARN_ON(!size)) {
+ xe_bo_free(bo);
return ERR_PTR(-EINVAL);
+ }
if (!bo) {
bo = xe_bo_alloc();
@@ -1239,8 +1241,10 @@ struct xe_bo *__xe_bo_create_locked(struct xe_device *xe, struct xe_bo *bo,
if (!(flags & XE_BO_FIXED_PLACEMENT_BIT)) {
err = __xe_bo_placement_for_flags(xe, bo, bo->flags);
- if (WARN_ON(err))
+ if (WARN_ON(err)) {
+ xe_ttm_bo_destroy(&bo->ttm);
return ERR_PTR(err);
+ }
}
/* Defer populating type_sg bos */