From 76356395e77442599cb3642fcb4551056b24f76a Mon Sep 17 00:00:00 2001 From: stefan11111 Date: Thu, 22 Jan 2026 23:32:12 +0200 Subject: [PATCH] kdrive/fbdev: Fix uninitialized variable when switching vt's When rapidly switching vt's, it can happen that shadow tries to draw to the screen before it's initialized. In that case, we return NULL, and we should also return a zero size, because shadow doesn't check for NULL. Signed-off-by: stefan11111 --- hw/kdrive/fbdev/fbdev.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/hw/kdrive/fbdev/fbdev.c b/hw/kdrive/fbdev/fbdev.c index 2329d8b15..1edc868f3 100644 --- a/hw/kdrive/fbdev/fbdev.c +++ b/hw/kdrive/fbdev/fbdev.c @@ -318,8 +318,10 @@ fbdevWindowLinear(ScreenPtr pScreen, KdScreenPriv(pScreen); FbdevPriv *priv = pScreenPriv->card->driver; - if (!pScreenPriv->enabled) - return 0; + if (!pScreenPriv->enabled) { + *size = 0; + return NULL; + } *size = priv->fix.line_length; return (CARD8 *) priv->fb + row * priv->fix.line_length + offset; } @@ -332,8 +334,10 @@ fbdevWindowAfb(ScreenPtr pScreen, KdScreenPriv(pScreen); FbdevPriv *priv = pScreenPriv->card->driver; - if (!pScreenPriv->enabled) - return 0; + if (!pScreenPriv->enabled) { + *size = 0; + return NULL; + } /* offset to next plane */ *size = priv->var.yres_virtual * priv->fix.line_length; return (CARD8 *) priv->fb + row * priv->fix.line_length + offset;