summaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
authorMichael Shalayeff <mickey@cvs.openbsd.org>2001-02-09 20:48:25 +0000
committerMichael Shalayeff <mickey@cvs.openbsd.org>2001-02-09 20:48:25 +0000
commit225418b1b154c2d8789feb8a3cf37c4edc07bfe6 (patch)
treeeecbdeffda7cbc60a8a8cce0cd6131108f38e893 /sys/dev
parent7b15a00ce8e276df839ae8bbabf0f2685797db77 (diff)
check dev in cn_tab for sanity, better than pagefaulting
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/cons.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/sys/dev/cons.c b/sys/dev/cons.c
index 4cd2c5b558d..f2a017da15a 100644
--- a/sys/dev/cons.c
+++ b/sys/dev/cons.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cons.c,v 1.7 1996/04/21 22:19:48 deraadt Exp $ */
+/* $OpenBSD: cons.c,v 1.8 2001/02/09 20:48:24 mickey Exp $ */
/* $NetBSD: cons.c,v 1.30 1996/04/08 19:57:30 jonathan Exp $ */
/*
@@ -66,6 +66,7 @@ cnopen(dev, flag, mode, p)
int flag, mode;
struct proc *p;
{
+ dev_t cndev;
if (cn_tab == NULL)
return (0);
@@ -75,12 +76,18 @@ cnopen(dev, flag, mode, p)
* later. This follows normal device semantics; they always get
* open() calls.
*/
- dev = cn_tab->cn_dev;
+ cndev = cn_tab->cn_dev;
+ if (cndev == NODEV)
+ return (ENXIO);
+#ifdef DIAGNOSTIC
+ if (cndev == dev)
+ panic("cnopen: recursive");
+#endif
if (cn_devvp == NULLVP) {
/* try to get a reference on its vnode, but fail silently */
- cdevvp(dev, &cn_devvp);
+ cdevvp(cndev, &cn_devvp);
}
- return ((*cdevsw[major(dev)].d_open)(dev, flag, mode, p));
+ return ((*cdevsw[major(cndev)].d_open)(cndev, flag, mode, p));
}
int