summaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
authorMartin Pieuchot <mpi@cvs.openbsd.org>2014-02-04 12:03:13 +0000
committerMartin Pieuchot <mpi@cvs.openbsd.org>2014-02-04 12:03:13 +0000
commit233155347874ca93fc095b06af365784d8be882e (patch)
treee342858819a6b94db9dee776828e06195ac1d8b9 /sys/dev
parentf8e7956c208889ace5eabd267720a485cb08eafe (diff)
Make sure the USB device pointer is valid even if attach fails since
it is now checked to prevent any operation on the device. Problem found and fix tested by sebastia@
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/usb/uftdi.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/sys/dev/usb/uftdi.c b/sys/dev/usb/uftdi.c
index 50712bd81f1..a491202d4b0 100644
--- a/sys/dev/usb/uftdi.c
+++ b/sys/dev/usb/uftdi.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uftdi.c,v 1.70 2014/02/03 20:53:32 mpi Exp $ */
+/* $OpenBSD: uftdi.c,v 1.71 2014/02/04 12:03:12 mpi Exp $ */
/* $NetBSD: uftdi.c,v 1.14 2003/02/23 04:20:07 simonb Exp $ */
/*
@@ -799,6 +799,8 @@ uftdi_attach(struct device *parent, struct device *self, void *aux)
DPRINTFN(10,("\nuftdi_attach: sc=%p\n", sc));
+ sc->sc_udev = dev;
+
if (uaa->iface == NULL) {
/* Move the device into the configured state. */
err = usbd_set_config_index(dev, UFTDI_CONFIG_INDEX, 1);
@@ -819,7 +821,6 @@ uftdi_attach(struct device *parent, struct device *self, void *aux)
id = usbd_get_interface_descriptor(iface);
- sc->sc_udev = dev;
sc->sc_iface = iface;
if (uaa->release < 0x0200) {
@@ -891,7 +892,7 @@ uftdi_attach(struct device *parent, struct device *self, void *aux)
bad:
DPRINTF(("uftdi_attach: ATTACH ERROR\n"));
- usbd_deactivate(dev);
+ usbd_deactivate(sc->sc_udev);
}
int