[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20241009184951.4991-1-everestkc@everestkc.com.np>
Date: Wed, 9 Oct 2024 12:49:49 -0600
From: "Everest K.C." <everestkc@...restkc.com.np>
To: lucas.demarchi@...el.com,
thomas.hellstrom@...ux.intel.com,
rodrigo.vivi@...el.com,
maarten.lankhorst@...ux.intel.com,
mripard@...nel.org,
tzimmermann@...e.de,
airlied@...il.com,
simona@...ll.ch
Cc: "Everest K.C." <everestkc@...restkc.com.np>,
skhan@...uxfoundation.org,
intel-xe@...ts.freedesktop.org,
dri-devel@...ts.freedesktop.org,
kernel-janitors@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: [PATCH][next] drm/xe/guc: Fix dereference before Null check
The pointer list->list was derefrenced before the Null check
resulting in possibility of Null pointer derefrencing.
This patch moves the Null check outside the for loop, so that
the check is performed before the derefrencing.
This issue was reported by Coverity Scan.
Signed-off-by: Everest K.C. <everestkc@...restkc.com.np>
---
drivers/gpu/drm/xe/xe_guc_capture.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/gpu/drm/xe/xe_guc_capture.c b/drivers/gpu/drm/xe/xe_guc_capture.c
index 41262bda20ed..de63c622747d 100644
--- a/drivers/gpu/drm/xe/xe_guc_capture.c
+++ b/drivers/gpu/drm/xe/xe_guc_capture.c
@@ -1537,13 +1537,13 @@ read_reg_to_node(struct xe_hw_engine *hwe, const struct __guc_mmio_reg_descr_gro
if (!regs)
return;
+ if (!list->list)
+ return;
+
for (i = 0; i < list->num_regs; i++) {
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 {
--
2.43.0
Powered by blists - more mailing lists