diff options
author | Jonathan Armani <armani@cvs.openbsd.org> | 2010-03-06 15:43:32 +0000 |
---|---|---|
committer | Jonathan Armani <armani@cvs.openbsd.org> | 2010-03-06 15:43:32 +0000 |
commit | a9bfd476fccf67c12ad222b86937f3833109f459 (patch) | |
tree | 463a22aa964e433e7d7c1de35a7429fbc558d914 /sys | |
parent | ff1e21695c53b2e7f1bbcd1f36682d52d9a223a7 (diff) |
Add a flag to know if the interface successfully attached like
other drivers do otherwise we panic trying to remove an unexistent
ifp during detach.
looks good to fabien@, with comments from mk@, ok mk
Diffstat (limited to 'sys')
-rw-r--r-- | sys/dev/usb/if_urndis.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/sys/dev/usb/if_urndis.c b/sys/dev/usb/if_urndis.c index d2f0dcdf35f..1653b052518 100644 --- a/sys/dev/usb/if_urndis.c +++ b/sys/dev/usb/if_urndis.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_urndis.c,v 1.9 2010/03/05 18:20:50 armani Exp $ */ +/* $OpenBSD: if_urndis.c,v 1.10 2010/03/06 15:43:31 armani Exp $ */ /* * Copyright (c) 2010 Jonathan Armani <dbd@asystant.net> @@ -1476,6 +1476,7 @@ urndis_attach(struct device *parent, struct device *self, void *aux) } else { printf("%s: invalid address\n", DEVNAME(sc)); free(buf, M_TEMP); + urndis_stop(sc); return; } @@ -1486,6 +1487,7 @@ urndis_attach(struct device *parent, struct device *self, void *aux) if (urndis_ctrl_set(sc, OID_GEN_CURRENT_PACKET_FILTER, &filter, sizeof(filter)) != RNDIS_STATUS_SUCCESS) { printf("%s: unable to set data filters\n", DEVNAME(sc)); + urndis_stop(sc); return; } @@ -1509,6 +1511,7 @@ urndis_attach(struct device *parent, struct device *self, void *aux) if_attach(ifp); ether_ifattach(ifp); + sc->sc_attached = 1; splx(s); @@ -1527,6 +1530,11 @@ urndis_detach(struct device *self, int flags) DPRINTF(("urndis_detach: %s flags %u\n", DEVNAME(sc), flags)); + + if (!sc->sc_attached) { + splx(s); + return 0; + } sc->sc_dying = 1; @@ -1536,6 +1544,7 @@ urndis_detach(struct device *self, int flags) if_detach(ifp); urndis_stop(sc); + sc->sc_attached = 0; splx(s); |