diff options
author | jlemon <jlemon@FreeBSD.org> | 2001-10-25 04:51:37 +0000 |
---|---|---|
committer | jlemon <jlemon@FreeBSD.org> | 2001-10-25 04:51:37 +0000 |
commit | 9b2f683d9cc9e1d0d6d3367d14f13a8bf00d37e7 (patch) | |
tree | dbe557211151effa1306182ed00e56ae98dcfe6d /sys | |
parent | fe5999a4cb5cb569e6d75d44a8cdf63c25a12f5c (diff) | |
download | FreeBSD-src-9b2f683d9cc9e1d0d6d3367d14f13a8bf00d37e7.zip FreeBSD-src-9b2f683d9cc9e1d0d6d3367d14f13a8bf00d37e7.tar.gz |
cnclose() can potentially race against itself. To avoid vn_close() races,
NULL-out cnd_vp before calling the latter, as it may block.
Submitted by: dillon
Diffstat (limited to 'sys')
-rw-r--r-- | sys/kern/tty_cons.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/sys/kern/tty_cons.c b/sys/kern/tty_cons.c index 441346c..55c7a87 100644 --- a/sys/kern/tty_cons.c +++ b/sys/kern/tty_cons.c @@ -381,12 +381,13 @@ static int cnclose(dev_t dev, int flag, int mode, struct thread *td) { struct cn_device *cnd; + struct vnode *vp; STAILQ_FOREACH(cnd, &cn_devlist, cnd_next) { - if (cnd->cnd_vp == NULL) + if ((vp = cnd->cnd_vp) == NULL) continue; - 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); } cn_is_open = 0; return (0); |