From bcca92c0e5a08caff315fa4ba590c6c6240dbe7f Mon Sep 17 00:00:00 2001 From: Ed Schouten Date: Fri, 2 Jan 2009 23:39:29 +0000 Subject: [PATCH] Fix a corner case in my previous commit. Even though there are not many setups that have absolutely no console device, make sure a close() on a TTY doesn't dereference a null pointer. --- sys/kern/tty.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sys/kern/tty.c b/sys/kern/tty.c index d1ed02fd657d..16901bbc273f 100644 --- a/sys/kern/tty.c +++ b/sys/kern/tty.c @@ -312,7 +312,8 @@ ttydev_close(struct cdev *dev, int fflag, int devtype, struct thread *td) * Don't actually close the device if it is being used as the * console. */ - if (strcmp(dev_console_filename, tty_devname(tp)) == 0) + if (dev_console_filename != NULL && + strcmp(dev_console_filename, tty_devname(tp)) == 0) return (0); tty_lock(tp);