Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/usb use sc_lock not sc_access_lock to check UHIDEV_O...



details:   https://anonhg.NetBSD.org/src/rev/6e5e04b29e87
branches:  trunk
changeset: 449781:6e5e04b29e87
user:      mrg <mrg%NetBSD.org@localhost>
date:      Sat Mar 23 02:19:31 2019 +0000

description:
use sc_lock not sc_access_lock to check UHIDEV_OPEN.

fixes a soft hang when usbhidaction has a uhid open and bzflag
tries to open it as well.

XXX: pullup-7, pullup-8 (where i saw this originally.)

diffstat:

 sys/dev/usb/uhid.c   |  12 +++++++-----
 sys/dev/usb/uhidev.h |   4 ++--
 2 files changed, 9 insertions(+), 7 deletions(-)

diffs (64 lines):

diff -r 216589df4a64 -r 6e5e04b29e87 sys/dev/usb/uhid.c
--- a/sys/dev/usb/uhid.c        Sat Mar 23 02:07:32 2019 +0000
+++ b/sys/dev/usb/uhid.c        Sat Mar 23 02:19:31 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: uhid.c,v 1.106 2019/03/01 11:06:56 pgoyette Exp $      */
+/*     $NetBSD: uhid.c,v 1.107 2019/03/23 02:19:31 mrg Exp $   */
 
 /*
  * Copyright (c) 1998, 2004, 2008, 2012 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uhid.c,v 1.106 2019/03/01 11:06:56 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uhid.c,v 1.107 2019/03/23 02:19:31 mrg Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -317,21 +317,23 @@
        if (sc->sc_dying)
                return ENXIO;
 
-       mutex_enter(&sc->sc_access_lock);
+       mutex_enter(&sc->sc_lock);
 
        /*
         * uhid interrupts aren't enabled yet, so setup sc_q now, as
         * long as they're not already allocated.
         */
        if (sc->sc_hdev.sc_state & UHIDEV_OPEN) {
-               mutex_exit(&sc->sc_access_lock);
+               mutex_exit(&sc->sc_lock);
                return EBUSY;
        }
+       mutex_exit(&sc->sc_lock);
+
        if (clalloc(&sc->sc_q, UHID_BSIZE, 0) == -1) {
-               mutex_exit(&sc->sc_access_lock);
                return ENOMEM;
        }
 
+       mutex_enter(&sc->sc_access_lock);
        error = uhidev_open(&sc->sc_hdev);
        if (error) {
                clfree(&sc->sc_q);
diff -r 216589df4a64 -r 6e5e04b29e87 sys/dev/usb/uhidev.h
--- a/sys/dev/usb/uhidev.h      Sat Mar 23 02:07:32 2019 +0000
+++ b/sys/dev/usb/uhidev.h      Sat Mar 23 02:19:31 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: uhidev.h,v 1.19 2016/04/23 10:15:32 skrll Exp $        */
+/*     $NetBSD: uhidev.h,v 1.20 2019/03/23 02:19:31 mrg Exp $  */
 
 /*
  * Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -67,8 +67,8 @@
        struct uhidev_softc *sc_parent;
        uByte sc_report_id;
        uint8_t sc_state;
+#define        UHIDEV_OPEN     0x01    /* device is open */
        int sc_in_rep_size;
-#define        UHIDEV_OPEN     0x01    /* device is open */
        void (*sc_intr)(struct uhidev *, void *, u_int);
        krndsource_t     rnd_source;
 };



Home | Main Index | Thread Index | Old Index