diff options
| author | mlelstv <mlelstv@NetBSD.org> | 2014-01-25 00:03:14 +0000 |
|---|---|---|
| committer | mlelstv <mlelstv@NetBSD.org> | 2014-01-25 00:03:14 +0000 |
| commit | e7dec7859571d8cb81f5260ade5df6558a9f35c5 (patch) | |
| tree | 31256452d62f710172905efebeedcbcaf82decad /sys/dev | |
| parent | e5ea90b5ff6310d43a041b7d63334f2492c52743 (diff) | |
close uhidev only when it was successfully opened.
Diffstat (limited to 'sys/dev')
| -rw-r--r-- | sys/dev/usb/ums.c | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/sys/dev/usb/ums.c b/sys/dev/usb/ums.c index 02c9dd7cc47..4d7745ba453 100644 --- a/sys/dev/usb/ums.c +++ b/sys/dev/usb/ums.c @@ -1,4 +1,4 @@ -/* $NetBSD: ums.c,v 1.86 2013/01/05 23:34:19 christos Exp $ */ +/* $NetBSD: ums.c,v 1.87 2014/01/25 00:03:14 mlelstv Exp $ */ /* * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -35,7 +35,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: ums.c,v 1.86 2013/01/05 23:34:19 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ums.c,v 1.87 2014/01/25 00:03:14 mlelstv Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -458,6 +458,7 @@ Static int ums_enable(void *v) { struct ums_softc *sc = v; + int error; DPRINTFN(1,("ums_enable: sc=%p\n", sc)); @@ -470,7 +471,11 @@ ums_enable(void *v) sc->sc_enabled = 1; sc->sc_buttons = 0; - return (uhidev_open(&sc->sc_hdev)); + error = uhidev_open(&sc->sc_hdev); + if (error) + sc->sc_enabled = 0; + + return error; } Static void @@ -486,8 +491,10 @@ ums_disable(void *v) } #endif - sc->sc_enabled = 0; - uhidev_close(&sc->sc_hdev); + if (sc->sc_enabled) { + sc->sc_enabled = 0; + uhidev_close(&sc->sc_hdev); + } } Static int |
