DragonFlyBSD Kernel Audit
DF-1801 / fix.diff
← back to finding ↓ download raw
diff --git a/sys/dev/misc/snp/snp.c b/sys/dev/misc/snp/snp.c
--- a/sys/dev/misc/snp/snp.c
+++ b/sys/dev/misc/snp/snp.c
@@ -262,6 +262,8 @@
 
 	snp = dev->si_drv1;
 	tp = snp->snp_tty;
+	if (tp == NULL)
+		return (EIO);
 	lwkt_gettoken(&tp->t_token);
 	KASSERT(snp->snp_len + snp->snp_base <= snp->snp_blen,
 	    ("snoop buffer error"));
@@ -633,6 +635,8 @@
 	struct klist *klist;
 	struct tty *tp = snp->snp_tty;
 
+	if (tp == NULL)
+		return (ENXIO);
 	lwkt_gettoken(&tp->t_token);
 	ap->a_result = 0;
 
@@ -675,6 +679,8 @@
 	struct tty *tp = snp->snp_tty;
 	int ready = 0;
 
+	if (tp == NULL)
+		return (0);
 	lwkt_gettoken(&tp->t_token);
 	/*
 	 * If snoop is down, we don't want to poll forever so we return 1.