From 415285a25050d13ac8217159058b900f2e32a80f Mon Sep 17 00:00:00 2001
From: dd
Date: Sun, 27 May 2001 00:57:25 +0000
Subject: [PATCH] In the VIRTUAL_TTY macro, add a check to make sure that the
result of SC_DEV isn't NULL; if it is, evaluate to NULL and don't dereference
NULL. Callers of VIRTUAL_TTY must already check for the result being NULL
since si_tty can be NULL, so this should be safe.
This fixes a panic when trying to switch to a different vty in an
environment such as userconfig (-c option to the kernel).
PR: 26508
---
sys/dev/syscons/syscons.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/sys/dev/syscons/syscons.c b/sys/dev/syscons/syscons.c
index f3305c4eb8e9..685b992d54f6 100644
--- a/sys/dev/syscons/syscons.c
+++ b/sys/dev/syscons/syscons.c
@@ -124,7 +124,8 @@ SYSCTL_INT(_machdep, OID_AUTO, enable_panic_key, CTLFLAG_RW, &enable_panic_key,
#define SC_CONSOLECTL 255
-#define VIRTUAL_TTY(sc, x) (SC_DEV((sc), (x))->si_tty)
+#define VIRTUAL_TTY(sc, x) (SC_DEV((sc), (x)) != NULL ? \
+ SC_DEV((sc), (x))->si_tty : NULL)
static int debugger;