[bug report] drm/xe: Minor cleanup in LRC handling

Dan Carpenter dan.carpenter at linaro.org
Thu Aug 8 19:24:46 UTC 2024


Hello Niranjana Vishwanathapura,

Commit 85cfc412579c ("drm/xe: Minor cleanup in LRC handling") from
May 7, 2024 (linux-next), leads to the following Smatch static
checker warning:

	drivers/gpu/drm/xe/xe_lrc.c:1640 xe_lrc_snapshot_capture()
	error: we previously assumed 'lrc->bo' could be null (see line 1637)

drivers/gpu/drm/xe/xe_lrc.c
    1630 struct xe_lrc_snapshot *xe_lrc_snapshot_capture(struct xe_lrc *lrc)
    1631 {
    1632         struct xe_lrc_snapshot *snapshot = kmalloc(sizeof(*snapshot), GFP_NOWAIT);
    1633 
    1634         if (!snapshot)
    1635                 return NULL;
    1636 
    1637         if (lrc->bo && lrc->bo->vm)
                     ^^^^^^^
The check assumes that lrc->bo can be NULL

    1638                 xe_vm_get(lrc->bo->vm);
    1639 
--> 1640         snapshot->context_desc = xe_lrc_ggtt_addr(lrc);
                                                           ^^^
Dereferenced without checking inside the xe_lrc_ggtt_addr() function.

    1641         snapshot->indirect_context_desc = xe_lrc_indirect_ring_ggtt_addr(lrc);
    1642         snapshot->head = xe_lrc_ring_head(lrc);
    1643         snapshot->tail.internal = lrc->ring.tail;
    1644         snapshot->tail.memory = xe_lrc_ring_tail(lrc);
    1645         snapshot->start_seqno = xe_lrc_start_seqno(lrc);
    1646         snapshot->seqno = xe_lrc_seqno(lrc);
    1647         snapshot->lrc_bo = xe_bo_get(lrc->bo);
    1648         snapshot->lrc_offset = xe_lrc_pphwsp_offset(lrc);
    1649         snapshot->lrc_size = lrc->bo->size - snapshot->lrc_offset;
    1650         snapshot->lrc_snapshot = NULL;
    1651         snapshot->ctx_timestamp = xe_lrc_ctx_timestamp(lrc);
    1652         snapshot->ctx_job_timestamp = xe_lrc_ctx_job_timestamp(lrc);
    1653         return snapshot;
    1654 }

regards,
dan carpenter


More information about the Intel-xe mailing list