Module Name:    src
Committed By:   riastradh
Date:           Mon Aug  1 23:30:10 UTC 2022

Modified Files:
        src/sys/dev/wsfb: genfb.c

Log Message:
genfb: Handle uninitialized softc in genfb_enable/disable_polling.

This can happen due to janky MD kludgerosity like x86
x86_genfb_ddb_trap_callback, which should really be cleaned up, but
at least this might help with the recursive traps we've been seeing
in syzbot.


To generate a diff of this commit:
cvs rdiff -u -r1.89 -r1.90 src/sys/dev/wsfb/genfb.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/wsfb/genfb.c
diff -u src/sys/dev/wsfb/genfb.c:1.89 src/sys/dev/wsfb/genfb.c:1.90
--- src/sys/dev/wsfb/genfb.c:1.89	Sun Jul 17 13:10:54 2022
+++ src/sys/dev/wsfb/genfb.c	Mon Aug  1 23:30:10 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: genfb.c,v 1.89 2022/07/17 13:10:54 riastradh Exp $ */
+/*	$NetBSD: genfb.c,v 1.90 2022/08/01 23:30:10 riastradh Exp $ */
 
 /*-
  * Copyright (c) 2007 Michael Lorenz
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: genfb.c,v 1.89 2022/07/17 13:10:54 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: genfb.c,v 1.90 2022/08/01 23:30:10 riastradh Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -985,6 +985,9 @@ genfb_enable_polling(device_t dev)
 	struct genfb_softc *sc = device_private(dev);
 	struct genfb_private *scp = sc->sc_private;
 
+	if (scp == NULL)
+		return;
+
 	if (scp->sc_console_screen.scr_vd) {
 		SCREEN_ENABLE_DRAWING(&scp->sc_console_screen);
 		vcons_hard_switch(&scp->sc_console_screen);
@@ -1000,6 +1003,9 @@ genfb_disable_polling(device_t dev)
 	struct genfb_softc *sc = device_private(dev);
 	struct genfb_private *scp = sc->sc_private;
 
+	if (scp == NULL)
+		return;
+
 	if (scp->sc_console_screen.scr_vd) {
 		if (scp->sc_ops.genfb_disable_polling)
 			(*scp->sc_ops.genfb_disable_polling)(sc);

Reply via email to