kernel - Attempt to fix NULL pointer dereference during console switch
authorMatthew Dillon <dillon@apollo.backplane.com>
Tue, 29 Jan 2013 19:19:22 +0000 (11:19 -0800)
committerMatthew Dillon <dillon@apollo.backplane.com>
Tue, 29 Jan 2013 19:19:22 +0000 (11:19 -0800)
* Attempt to fix NULL pointer dereference during console switch.
  Bug 2481.

Reported-by: marino
sys/dev/misc/syscons/syscons.c

index c6a6cb5..afc9bbc 100644 (file)
@@ -1093,8 +1093,14 @@ scioctl(struct dev_ioctl_args *ap)
            lwkt_reltoken(&tty_token);
            return error;
        }
            lwkt_reltoken(&tty_token);
            return error;
        }
+
+       /*
+        * scp might be NULL, we aren't sure why.  Check for NULL.
+        *
+        * http://bugs.dragonflybsd.org/issues/2481
+        */
        scp = SC_STAT(SC_DEV(sc, i));
        scp = SC_STAT(SC_DEV(sc, i));
-       if (scp == scp->sc->cur_scp) {
+       if (scp == NULL || scp == scp->sc->cur_scp) {
            lwkt_reltoken(&tty_token);
            return 0;
        }
            lwkt_reltoken(&tty_token);
            return 0;
        }