summaryrefslogtreecommitdiffstats
path: root/sys/kern/tty.c
diff options
context:
space:
mode:
authored <ed@FreeBSD.org>2009-01-02 23:39:29 +0000
committered <ed@FreeBSD.org>2009-01-02 23:39:29 +0000
commitfa1537b9485c0b99a15acc74fd9f508e9e393d53 (patch)
tree53a4821044facdbd034ecd6a2f583b1719a5fbff /sys/kern/tty.c
parent8244396e7993d849d44c2b53c2407aa462e329d6 (diff)
downloadFreeBSD-src-fa1537b9485c0b99a15acc74fd9f508e9e393d53.zip
FreeBSD-src-fa1537b9485c0b99a15acc74fd9f508e9e393d53.tar.gz
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.
Diffstat (limited to 'sys/kern/tty.c')
-rw-r--r--sys/kern/tty.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/sys/kern/tty.c b/sys/kern/tty.c
index d1ed02f..16901bb 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);
OpenPOWER on IntegriCloud