Skip to contentSkip to conversation

i915/gvt: Fix NULL pointer dereference in init_mmio_block_handlers

PATCH New Wan Jiabing 2 participants 2 messages Apr 27, 2022 – Apr 28, 2022

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 i915/gvt: Fix NULL pointer dereference in init_mmio_block_handlers

Fix following coccicheck error:
./drivers/gpu/drm/i915/gvt/handlers.c:2925:35-41: ERROR: block is NULL but dereferenced.

Use gvt->mmio.mmio_block instead of block to avoid NULL pointer dereference when find_mmio_block returns NULL.

Fixes e0f74ed4634d ("i915/gvt: Separate the MMIO tracking table from GVT-g")
---
 drivers/gpu/drm/i915/gvt/handlers.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/i915/gvt/handlers.c +1 -1
index cf00398c2870..7ffe0fb512a9 100644
@@ -2922,7 +2922,7 @@ static int init_mmio_block_handlers(struct intel_gvt *gvt)
 	block = find_mmio_block(gvt, VGT_PVINFO_PAGE);
 	if (!block) {
 		WARN(1, "fail to assign handlers to mmio block %x\n",
-		     i915_mmio_reg_offset(block->offset));
+		     i915_mmio_reg_offset(gvt->mmio.mmio_block->offset));
 		return -ENODEV;
 	}
 
Signature · 1 line
2.35.3
#1 lore raw

[Intel-gfx] ✗ Fi.CI.BUILD: failure for i915/gvt: Fix NULL pointer dereference in init_mmio_block_handlers

== Series Details ==

== Series Details ==

Series: i915/gvt: Fix NULL pointer dereference in init_mmio_block_handlers
URL : https://patchwork.freedesktop.org/series/103261/
State : failure

== Summary ==

Error: patch https://patchwork.freedesktop.org/api/1.0/series/103261/revisions/1/mbox/ not applied
Applying: i915/gvt: Fix NULL pointer dereference in init_mmio_block_handlers
Using index info to reconstruct a base tree...
M drivers/gpu/drm/i915/gvt/handlers.c
Falling back to patching base and 3-way merge...
Auto-merging drivers/gpu/drm/i915/gvt/handlers.c
CONFLICT (content): Merge conflict in drivers/gpu/drm/i915/gvt/handlers.c
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
Patch failed at 0001 i915/gvt: Fix NULL pointer dereference in init_mmio_block_handlers When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".