Skip to content

Commit 6d9f911

Browse files
everestkcThomas Hellström
authored andcommitted
drm/xe/guc: Fix dereference before NULL check
The pointer list->list is dereferenced before the NULL check. Fix this by moving the NULL check outside the for loop, so that the check is performed before the dereferencing. The list->list pointer cannot be NULL so this has no effect on runtime. It's just a correctness issue. This issue was reported by Coverity Scan. https://scan7.scan.coverity.com/#/project-view/51525/11354?selectedIssue=1600335 Fixes: 0f1fdf5 ("drm/xe/guc: Save manual engine capture into capture list") Signed-off-by: Everest K.C. <everestkc@everestkc.com.np> Reviewed-by: Dan Carpenter <dan.carpenter@linaro.org> Signed-off-by: John Harrison <John.C.Harrison@Intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/20241023233356.5479-1-everestkc@everestkc.com.np (cherry picked from commit 2aff81e) Signed-off-by: Thomas Hellström <thomas.hellstrom@linux.intel.com>
1 parent 56b70bf commit 6d9f911

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

drivers/gpu/drm/xe/xe_guc_capture.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1531,7 +1531,7 @@ read_reg_to_node(struct xe_hw_engine *hwe, const struct __guc_mmio_reg_descr_gro
15311531
{
15321532
int i;
15331533

1534-
if (!list || list->num_regs == 0)
1534+
if (!list || !list->list || list->num_regs == 0)
15351535
return;
15361536

15371537
if (!regs)
@@ -1541,9 +1541,6 @@ read_reg_to_node(struct xe_hw_engine *hwe, const struct __guc_mmio_reg_descr_gro
15411541
struct __guc_mmio_reg_descr desc = list->list[i];
15421542
u32 value;
15431543

1544-
if (!list->list)
1545-
return;
1546-
15471544
if (list->type == GUC_STATE_CAPTURE_TYPE_ENGINE_INSTANCE) {
15481545
value = xe_hw_engine_mmio_read32(hwe, desc.reg);
15491546
} else {

0 commit comments

Comments
 (0)