Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/wsfb genfb: Handle uninitialized softc in genfb_enab...



details:   https://anonhg.NetBSD.org/src/rev/4c181d296387
branches:  trunk
changeset: 368755:4c181d296387
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Mon Aug 01 23:30:10 2022 +0000

description:
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.

diffstat:

 sys/dev/wsfb/genfb.c |  10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)

diffs (38 lines):

diff -r f0d9df74fa48 -r 4c181d296387 sys/dev/wsfb/genfb.c
--- a/sys/dev/wsfb/genfb.c      Mon Aug 01 15:48:39 2022 +0000
+++ b/sys/dev/wsfb/genfb.c      Mon Aug 01 23:30:10 2022 +0000
@@ -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 @@
        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 @@
        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);



Home | Main Index | Thread Index | Old Index