Skip to content

Commit 09a8f3c

Browse files
ShuichengLinrodrigovivi
authored andcommitted
drm/xe/bo: Fix bo leak on unaligned size validation in xe_bo_init_locked()
When type is ttm_bo_type_device and aligned_size != size, the function returns an error without freeing a caller-provided bo, violating the documented contract that bo is freed on failure. Add xe_bo_free(bo) before returning the error. Fixes: 4e03b58 ("drm/xe/uapi: Reject bo creation of unaligned size") Cc: stable@vger.kernel.org Assisted-by: Claude:claude-opus-4.6 Reviewed-by: Matthew Brost <matthew.brost@intel.com> Link: https://patch.msgid.link/20260408175255.3402838-2-shuicheng.lin@intel.com Signed-off-by: Shuicheng Lin <shuicheng.lin@intel.com> (cherry picked from commit 601c2aa) Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
1 parent f8c4151 commit 09a8f3c

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

drivers/gpu/drm/xe/xe_bo.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2342,8 +2342,10 @@ struct xe_bo *xe_bo_init_locked(struct xe_device *xe, struct xe_bo *bo,
23422342
alignment = SZ_4K >> PAGE_SHIFT;
23432343
}
23442344

2345-
if (type == ttm_bo_type_device && aligned_size != size)
2345+
if (type == ttm_bo_type_device && aligned_size != size) {
2346+
xe_bo_free(bo);
23462347
return ERR_PTR(-EINVAL);
2348+
}
23472349

23482350
if (!bo) {
23492351
bo = xe_bo_alloc();

0 commit comments

Comments
 (0)