From 5dd2cd84fe935437286d31918a2e395dd887d352 Mon Sep 17 00:00:00 2001 From: phk Date: Fri, 24 Sep 2004 08:12:41 +0000 Subject: Hold thread reference while we frob cdevsw. --- sys/dev/snp/snp.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'sys/dev/snp') diff --git a/sys/dev/snp/snp.c b/sys/dev/snp/snp.c index 6103a5d..a414d7c 100644 --- a/sys/dev/snp/snp.c +++ b/sys/dev/snp/snp.c @@ -184,11 +184,17 @@ snpdevtotty(dev) struct cdev *dev; { struct cdevsw *cdp; + struct tty *tp; - cdp = devsw(dev); - if (cdp == NULL || (cdp->d_flags & D_TTY) == 0) + cdp = dev_refthread(dev); + if (cdp == NULL) return (NULL); - return (dev->si_tty); + if (!(cdp->d_flags & D_TTY)) + tp = NULL; + else + tp = dev->si_tty; + dev_relthread(dev); + return (tp); } #define SNP_INPUT_BUF 5 /* This is even too much, the maximal -- cgit v1.1