summaryrefslogtreecommitdiffstats
path: root/sys/kern/tty_cons.c
diff options
context:
space:
mode:
authorjlemon <jlemon@FreeBSD.org>2001-11-02 17:04:32 +0000
committerjlemon <jlemon@FreeBSD.org>2001-11-02 17:04:32 +0000
commita17e2c0c4408996307edf2dee263e96b99339a92 (patch)
tree44962cae93e1182d6eef9b2d3b633f73841014f1 /sys/kern/tty_cons.c
parent41e6d511f21a24ad647c43b18403425ea436b888 (diff)
downloadFreeBSD-src-a17e2c0c4408996307edf2dee263e96b99339a92.zip
FreeBSD-src-a17e2c0c4408996307edf2dee263e96b99339a92.tar.gz
+ Fix another possible vn_close race, in the same fashion as r1.95.
+ Check that the cached vnode type != VBAD before calling devsw(), this can happen if the vnode has been revoked.
Diffstat (limited to 'sys/kern/tty_cons.c')
-rw-r--r--sys/kern/tty_cons.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/sys/kern/tty_cons.c b/sys/kern/tty_cons.c
index 55c7a87..d25e420 100644
--- a/sys/kern/tty_cons.c
+++ b/sys/kern/tty_cons.c
@@ -334,17 +334,18 @@ static int
cn_devopen(struct cn_device *cnd, struct thread *td, int forceopen)
{
char path[CNDEVPATHMAX];
- struct nameidata nd;
+ struct nameidata nd;
+ struct vnode *vp;
dev_t dev;
int error;
- if (cnd->cnd_vp != NULL) {
- if (!forceopen) {
- dev = cnd->cnd_vp->v_rdev;
+ if ((vp = cnd->cnd_vp) != NULL) {
+ if (!forceopen && vp->v_type != VBAD) {
+ dev = vp->v_rdev;
return ((*devsw(dev)->d_open)(dev, openflag, 0, td));
}
- vn_close(cnd->cnd_vp, openflag, td->td_proc->p_ucred, td);
cnd->cnd_vp = NULL;
+ vn_close(vp, openflag, td->td_proc->p_ucred, td);
}
if (cnd->cnd_name[0] == '\0')
strncpy(cnd->cnd_name, devtoname(cnd->cnd_cn->cn_dev),
OpenPOWER on IntegriCloud