Check for tp->t_refcnt == 0 before doing anything in tty_open().
PR: 103520 MFC after: 1 week
This commit is contained in:
parent
d3ff3b5f2f
commit
7c56049e6d
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=162575
@ -3067,6 +3067,12 @@ ttyopen(struct cdev *dev, int flag, int mode, struct thread *td)
|
||||
struct tty *tp;
|
||||
|
||||
tp = dev->si_tty;
|
||||
|
||||
/* XXX It can happen that devfs_open calls us with tp->t_refcnt == 0 */
|
||||
if (tp == NULL || tp->t_refcnt == 0) {
|
||||
return (ENXIO);
|
||||
}
|
||||
|
||||
s = spltty();
|
||||
/*
|
||||
* We jump to this label after all non-interrupted sleeps to pick
|
||||
|
@ -196,6 +196,12 @@ ptsopen(struct cdev *dev, int flag, int devtype, struct thread *td)
|
||||
return(ENXIO);
|
||||
pt = dev->si_drv1;
|
||||
tp = dev->si_tty;
|
||||
|
||||
/* XXX It can happen that devfs_open calls us with tp->t_refcnt == 0 */
|
||||
if (tp == NULL || tp->t_refcnt == 0) {
|
||||
return (ENXIO);
|
||||
}
|
||||
|
||||
if ((tp->t_state & TS_ISOPEN) == 0) {
|
||||
ttyinitmode(tp, 1, 0);
|
||||
} else if (tp->t_state & TS_XCLUDE && suser(td))
|
||||
@ -314,6 +320,12 @@ ptcopen(struct cdev *dev, int flag, int devtype, struct thread *td)
|
||||
if (!dev->si_drv1)
|
||||
return(ENXIO);
|
||||
tp = dev->si_tty;
|
||||
|
||||
/* XXX It can happen that devfs_open calls us with tp->t_refcnt == 0 */
|
||||
if (tp == NULL || tp->t_refcnt == 0) {
|
||||
return (ENXIO);
|
||||
}
|
||||
|
||||
if (tp->t_oproc)
|
||||
return (EIO);
|
||||
tp->t_timeout = -1;
|
||||
|
Loading…
Reference in New Issue
Block a user