]> Git Repo - J-linux.git/commitdiff
drm/xe/guc: Fix dereference before NULL check
authorEverest K.C. <[email protected]>
Wed, 23 Oct 2024 23:33:55 +0000 (17:33 -0600)
committerThomas Hellström <[email protected]>
Thu, 14 Nov 2024 13:55:01 +0000 (14:55 +0100)
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: 0f1fdf559225 ("drm/xe/guc: Save manual engine capture into capture list")
Signed-off-by: Everest K.C. <[email protected]>
Reviewed-by: Dan Carpenter <[email protected]>
Signed-off-by: John Harrison <[email protected]>
Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
(cherry picked from commit 2aff81e039de5b0b7ef6bdcb2c320f121f69e2b4)
Signed-off-by: Thomas Hellström <[email protected]>
drivers/gpu/drm/xe/xe_guc_capture.c

index 8b6cb786a2aaf349879355ae39353c63840dd5a9..cc72446a5de11a3e0776eb449571a0b4d9ebf9df 100644 (file)
@@ -1531,7 +1531,7 @@ read_reg_to_node(struct xe_hw_engine *hwe, const struct __guc_mmio_reg_descr_gro
 {
        int i;
 
-       if (!list || list->num_regs == 0)
+       if (!list || !list->list || list->num_regs == 0)
                return;
 
        if (!regs)
@@ -1541,9 +1541,6 @@ read_reg_to_node(struct xe_hw_engine *hwe, const struct __guc_mmio_reg_descr_gro
                struct __guc_mmio_reg_descr desc = list->list[i];
                u32 value;
 
-               if (!list->list)
-                       return;
-
                if (list->type == GUC_STATE_CAPTURE_TYPE_ENGINE_INSTANCE) {
                        value = xe_hw_engine_mmio_read32(hwe, desc.reg);
                } else {
This page took 0.054483 seconds and 4 git commands to generate.