summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authorderaadt <deraadt@openbsd.org>2006-03-27 06:14:52 +0000
committerderaadt <deraadt@openbsd.org>2006-03-27 06:14:52 +0000
commit77201ced0fced462cb3c948cbd7f1a6aa6a26917 (patch)
tree5c832ad35de545b894d8bac75cd3a17a5b5d27ec /sys
parentPlug a memory leak for all cvs_strsplit call sites; ok xsa@ (diff)
downloadwireguard-openbsd-77201ced0fced462cb3c948cbd7f1a6aa6a26917.tar.xz
wireguard-openbsd-77201ced0fced462cb3c948cbd7f1a6aa6a26917.zip
in detach, mark device with COM_SW_DEAD, so that close() will not go
tapping additional registes. allows it to work on macppc, where doing such a tap after unplug is very bad. drahn helped fkr@bytemine.de ok miod and drahn
Diffstat (limited to 'sys')
-rw-r--r--sys/dev/ic/com.c7
-rw-r--r--sys/dev/ic/comvar.h3
2 files changed, 8 insertions, 2 deletions
diff --git a/sys/dev/ic/com.c b/sys/dev/ic/com.c
index 2314b4205ac..cd245649229 100644
--- a/sys/dev/ic/com.c
+++ b/sys/dev/ic/com.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: com.c,v 1.109 2006/01/01 11:59:40 miod Exp $ */
+/* $OpenBSD: com.c,v 1.110 2006/03/27 06:14:52 deraadt Exp $ */
/* $NetBSD: com.c,v 1.82.4.1 1996/06/02 09:08:00 mrg Exp $ */
/*
@@ -207,6 +207,8 @@ com_detach(self, flags)
struct com_softc *sc = (struct com_softc *)self;
int maj, mn;
+ sc->sc_swflags |= COM_SW_DEAD;
+
/* locate the major number */
for (maj = 0; maj < nchrdev; maj++)
if (cdevsw[maj].d_open == comopen)
@@ -501,6 +503,9 @@ comclose(dev, flag, mode, p)
return 0;
#endif
+ if(sc->sc_swflags & COM_SW_DEAD)
+ return 0;
+
(*linesw[tp->t_line].l_close)(tp, flag);
s = spltty();
if (ISSET(tp->t_state, TS_WOPEN)) {
diff --git a/sys/dev/ic/comvar.h b/sys/dev/ic/comvar.h
index 3cbb457be78..7ee7cb7d7cc 100644
--- a/sys/dev/ic/comvar.h
+++ b/sys/dev/ic/comvar.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: comvar.h,v 1.37 2005/10/24 14:22:34 fgsch Exp $ */
+/* $OpenBSD: comvar.h,v 1.38 2006/03/27 06:14:52 deraadt Exp $ */
/* $NetBSD: comvar.h,v 1.5 1996/05/05 19:50:47 christos Exp $ */
/*
@@ -117,6 +117,7 @@ struct com_softc {
#define COM_SW_CRTSCTS 0x04
#define COM_SW_MDMBUF 0x08
#define COM_SW_PPS 0x10
+#define COM_SW_DEAD 0x20
int sc_fifolen;
u_char sc_msr, sc_mcr, sc_lcr, sc_ier;
u_char sc_dtr;