aboutsummaryrefslogtreecommitdiff
path: root/sys/dev/snp/snp.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/dev/snp/snp.c')
-rw-r--r--sys/dev/snp/snp.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/sys/dev/snp/snp.c b/sys/dev/snp/snp.c
index 3bcd2263809b..37c1c075a76e 100644
--- a/sys/dev/snp/snp.c
+++ b/sys/dev/snp/snp.c
@@ -125,6 +125,7 @@ snp_dtor(void *data)
tty_lock(tp);
ttyoutq_free(&ss->snp_outq);
ttyhook_unregister(tp);
+ ss->snp_tty = NULL;
}
cv_destroy(&ss->snp_outwait);
@@ -252,9 +253,19 @@ snp_ioctl(struct cdev *dev, u_long cmd, caddr_t data, int flags,
case SNPSTTY:
/* Bind TTY to snoop instance. */
SNP_LOCK();
- if (ss->snp_tty != NULL) {
+ tp = ss->snp_tty;
+ if (tp != NULL) {
+ if (*(int *)data == -1) {
+ tty_lock(tp);
+ ss->snp_tty = NULL;
+ ttyoutq_free(&ss->snp_outq);
+ ttyhook_unregister(tp);
+ error = 0;
+ } else {
+ error = EBUSY;
+ }
SNP_UNLOCK();
- return (EBUSY);
+ return (error);
}
/*
* XXXRW / XXXJA: no capability check here.