Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/usb close uhidev only when it was successfully opened.



details:   https://anonhg.NetBSD.org/src/rev/dc52cf4fa090
branches:  trunk
changeset: 326295:dc52cf4fa090
user:      mlelstv <mlelstv%NetBSD.org@localhost>
date:      Sat Jan 25 00:03:14 2014 +0000

description:
close uhidev only when it was successfully opened.

diffstat:

 sys/dev/usb/ums.c |  17 ++++++++++++-----
 1 files changed, 12 insertions(+), 5 deletions(-)

diffs (52 lines):

diff -r 4fe02f013aed -r dc52cf4fa090 sys/dev/usb/ums.c
--- a/sys/dev/usb/ums.c Fri Jan 24 23:59:53 2014 +0000
+++ b/sys/dev/usb/ums.c Sat Jan 25 00:03:14 2014 +0000
@@ -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 @@
 ums_enable(void *v)
 {
        struct ums_softc *sc = v;
+       int error;
 
        DPRINTFN(1,("ums_enable: sc=%p\n", sc));
 
@@ -470,7 +471,11 @@
        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 @@
        }
 #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



Home | Main Index | Thread Index | Old Index