diff options
author | sam <sam@FreeBSD.org> | 2007-09-07 03:54:54 +0000 |
---|---|---|
committer | sam <sam@FreeBSD.org> | 2007-09-07 03:54:54 +0000 |
commit | bf5d382aa7ca3d8b0a5b6e8c6b078c068d81071d (patch) | |
tree | 84774fa570780c8e22ba84f8a0245a55adc4e237 /sys/dev/usb | |
parent | 9bc4ef52849c5ff2fd268abfe9aa1f6071044e7a (diff) | |
download | FreeBSD-src-bf5d382aa7ca3d8b0a5b6e8c6b078c068d81071d.zip FreeBSD-src-bf5d382aa7ca3d8b0a5b6e8c6b078c068d81071d.tar.gz |
- fix a bug that zyd_attach() returns 0 even if it encountered errors
that can lead to a panic when the stick is yanked.
- make sure that zyd_attach() returns 0 or errno.
Submitted by: Weongyo Jeong <weongyo.jeong@gmail.com>
Reported by: Ted Lindgreen <ted@tednet.nl>
Reviewed by: sam
Approved by: re (blanket wireless)
Diffstat (limited to 'sys/dev/usb')
-rw-r--r-- | sys/dev/usb/if_zyd.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/sys/dev/usb/if_zyd.c b/sys/dev/usb/if_zyd.c index 6251150..76df578 100644 --- a/sys/dev/usb/if_zyd.c +++ b/sys/dev/usb/if_zyd.c @@ -271,6 +271,7 @@ zyd_attachhook(struct zyd_softc *sc) static int zyd_attach(device_t dev) { + int error = ENXIO; struct zyd_softc *sc = device_get_softc(dev); struct usb_attach_arg *uaa = device_get_ivars(dev); usb_device_descriptor_t* ddesc; @@ -293,7 +294,7 @@ zyd_attach(device_t dev) device_printf(dev, "device version mismatch: 0x%x " "(only >= 43.30 supported)\n", UGETW(ddesc->bcdDevice)); - return -1; + goto bad; } ifp->if_softc = sc; @@ -307,7 +308,12 @@ zyd_attach(device_t dev) STAILQ_INIT(&sc->sc_rqh); - zyd_attachhook(sc); + error = zyd_attachhook(sc); + if (error != 0) { +bad: + if_free(ifp); + return error; + } return 0; } @@ -332,6 +338,7 @@ zyd_complete_attach(struct zyd_softc *sc) error = usbd_set_config_no(sc->sc_udev, ZYD_CONFIG_NO, 1); if (error != 0) { device_printf(sc->sc_dev, "setting config no failed\n"); + error = ENXIO; goto fail; } @@ -339,6 +346,7 @@ zyd_complete_attach(struct zyd_softc *sc) &sc->sc_iface); if (error != 0) { device_printf(sc->sc_dev, "getting interface handle failed\n"); + error = ENXIO; goto fail; } @@ -522,7 +530,7 @@ zyd_open_pipes(struct zyd_softc *sc) return 0; fail: zyd_close_pipes(sc); - return error; + return ENXIO; } static void |