mirror of
https://github.com/torvalds/linux.git
synced 2025-12-07 20:06:24 +00:00
drm/xe: Add NULL checks to scratch LRC allocation
kmalloc can fail, the returned value must have a NULL check. This should be immediately after kmalloc for clarity. v5: - Assert state->buffer in setup_bo if buffer is iomem (Tomasz) Signed-off-by: Matthew Brost <matthew.brost@intel.com> Reviewed-by: Tomasz Lis <tomasz.lis@intel.com> Link: https://lore.kernel.org/r/20251008214532.3442967-2-matthew.brost@intel.com
This commit is contained in:
@@ -1214,8 +1214,7 @@ static int setup_bo(struct bo_setup_state *state)
|
||||
ssize_t remain;
|
||||
|
||||
if (state->lrc->bo->vmap.is_iomem) {
|
||||
if (!state->buffer)
|
||||
return -ENOMEM;
|
||||
xe_gt_assert(state->hwe->gt, state->buffer);
|
||||
state->ptr = state->buffer;
|
||||
} else {
|
||||
state->ptr = state->lrc->bo->vmap.vaddr + state->offset;
|
||||
@@ -1303,8 +1302,11 @@ static int setup_wa_bb(struct xe_lrc *lrc, struct xe_hw_engine *hwe)
|
||||
u32 *buf = NULL;
|
||||
int ret;
|
||||
|
||||
if (lrc->bo->vmap.is_iomem)
|
||||
if (lrc->bo->vmap.is_iomem) {
|
||||
buf = kmalloc(LRC_WA_BB_SIZE, GFP_KERNEL);
|
||||
if (!buf)
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
ret = xe_lrc_setup_wa_bb_with_scratch(lrc, hwe, buf);
|
||||
|
||||
@@ -1347,8 +1349,11 @@ setup_indirect_ctx(struct xe_lrc *lrc, struct xe_hw_engine *hwe)
|
||||
if (xe_gt_WARN_ON(lrc->gt, !state.funcs))
|
||||
return 0;
|
||||
|
||||
if (lrc->bo->vmap.is_iomem)
|
||||
if (lrc->bo->vmap.is_iomem) {
|
||||
state.buffer = kmalloc(state.max_size, GFP_KERNEL);
|
||||
if (!state.buffer)
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
ret = setup_bo(&state);
|
||||
if (ret) {
|
||||
|
||||
Reference in New Issue
Block a user