From: visa Date: Tue, 14 Dec 2021 15:32:20 +0000 (+0000) Subject: Cover all state checks and updates with spltty() in filt_ttyread(). X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=15092f8225f743ef5833e3e37b71ebbd17b74fba;p=openbsd Cover all state checks and updates with spltty() in filt_ttyread(). --- diff --git a/sys/kern/tty.c b/sys/kern/tty.c index 9dfe18756ed..37e9ab5efbd 100644 --- a/sys/kern/tty.c +++ b/sys/kern/tty.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tty.c,v 1.171 2021/12/02 15:13:49 deraadt Exp $ */ +/* $OpenBSD: tty.c,v 1.172 2021/12/14 15:32:20 visa Exp $ */ /* $NetBSD: tty.c,v 1.68.4.2 1996/06/06 16:04:52 thorpej Exp $ */ /*- @@ -1154,18 +1154,19 @@ int filt_ttyread(struct knote *kn, long hint) { struct tty *tp = kn->kn_hook; - int s; + int active, s; s = spltty(); kn->kn_data = ttnread(tp); - splx(s); + active = (kn->kn_data > 0); if (!ISSET(tp->t_cflag, CLOCAL) && !ISSET(tp->t_state, TS_CARR_ON)) { kn->kn_flags |= EV_EOF; if (kn->kn_flags & __EV_POLL) kn->kn_flags |= __EV_HUP; - return (1); + active = 1; } - return (kn->kn_data > 0); + splx(s); + return (active); } void