mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] drm/i915/gvt: Fix NULL pointer dereference in slot switch
@ 2026-11-12 15:58 Tuo Li
  2026-11-17  1:01 ` Zhenyu Wang
  0 siblings, 1 reply; 2+ messages in thread
From: Tuo Li @ 2026-11-12 15:58 UTC (permalink / raw)
  To: zhenyuw.linux, zhi.wang.linux, jani.nikula, joonas.lahtinen,
	rodrigo.vivi, tursulin, airlied, simona, ankit.k.nautiyal
  Cc: intel-gfx, dri-devel, linux-kernel, Tuo Li

The running slot is updated to the pending slot before updating the running
context. However, the condition checks the old running context instead of
the newly assigned running slot.

When no pending slot exists, running_slot becomes NULL. If the previous
running_context is non-NULL, the code attempts to access
running_slot->ctx[0], resulting in a NULL pointer dereference.

To fix this possible NULL pointer dereference, check running_slot instead
to ensure that running_context is updated only when a valid slot is
available.

Fixes: 8453d674ae7e ("drm/i915/gvt: vGPU execlist virtualization")
Signed-off-by: Tuo Li <islituo@gmail.com>
---
 drivers/gpu/drm/i915/gvt/execlist.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/i915/gvt/execlist.c b/drivers/gpu/drm/i915/gvt/execlist.c
index 29147a9f162e..763c310f2aaf 100644
--- a/drivers/gpu/drm/i915/gvt/execlist.c
+++ b/drivers/gpu/drm/i915/gvt/execlist.c
@@ -73,7 +73,7 @@ static void switch_virtual_execlist_slot(struct intel_vgpu_execlist *execlist)
 
 	execlist->running_slot = execlist->pending_slot;
 	execlist->pending_slot = NULL;
-	execlist->running_context = execlist->running_context ?
+	execlist->running_context = execlist->running_slot ?
 		&execlist->running_slot->ctx[0] : NULL;
 
 	gvt_dbg_el("[after] running slot %d/context %x pending slot %d\n",
-- 
2.43.0


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] drm/i915/gvt: Fix NULL pointer dereference in slot switch
  2026-11-12 15:58 [PATCH] drm/i915/gvt: Fix NULL pointer dereference in slot switch Tuo Li
@ 2026-11-17  1:01 ` Zhenyu Wang
  0 siblings, 0 replies; 2+ messages in thread
From: Zhenyu Wang @ 2026-11-17  1:01 UTC (permalink / raw)
  To: Tuo Li
  Cc: zhi.wang.linux, jani.nikula, joonas.lahtinen, rodrigo.vivi,
	tursulin, airlied, simona, ankit.k.nautiyal, intel-gfx,
	dri-devel, linux-kernel

On Thu, Nov 12, 2026 at 11:58:22PM +0800, Tuo Li wrote:
> The running slot is updated to the pending slot before updating the running
> context. However, the condition checks the old running context instead of
> the newly assigned running slot.
> 
> When no pending slot exists, running_slot becomes NULL. If the previous
> running_context is non-NULL, the code attempts to access
> running_slot->ctx[0], resulting in a NULL pointer dereference.
> 
> To fix this possible NULL pointer dereference, check running_slot instead
> to ensure that running_context is updated only when a valid slot is
> available.

Well, just AI generated static check but without any runtime analysis,
again...and can't even show kernel oops of this, as it simply can't happen..

> 
> Fixes: 8453d674ae7e ("drm/i915/gvt: vGPU execlist virtualization")
> Signed-off-by: Tuo Li <islituo@gmail.com>
> ---
>  drivers/gpu/drm/i915/gvt/execlist.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/i915/gvt/execlist.c b/drivers/gpu/drm/i915/gvt/execlist.c
> index 29147a9f162e..763c310f2aaf 100644
> --- a/drivers/gpu/drm/i915/gvt/execlist.c
> +++ b/drivers/gpu/drm/i915/gvt/execlist.c
> @@ -73,7 +73,7 @@ static void switch_virtual_execlist_slot(struct intel_vgpu_execlist *execlist)
>  
>  	execlist->running_slot = execlist->pending_slot;
>  	execlist->pending_slot = NULL;
> -	execlist->running_context = execlist->running_context ?
> +	execlist->running_context = execlist->running_slot ?
>  		&execlist->running_slot->ctx[0] : NULL;
>

Current code calls this switch in case whenever running_slot is
available, so it won't have null ptr reference. But code looks a
little weird, as current code tried to assign running_context in other
place e.g when new request happened, or even it might seem to miss
when enter execlist idle state...but it is still valid in switch
call. So I think this is just harmless. If you'd like for further
cleanup, that needs testing result for sure.

Thanks.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-11-17  1:01 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-12 15:58 [PATCH] drm/i915/gvt: Fix NULL pointer dereference in slot switch Tuo Li
2026-11-17  1:01 ` Zhenyu Wang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®