Source-Changes-HG archive

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

[src/netbsd-9]: src/sys/dev/usb Pull up following revision(s) (requested by s...



details:   https://anonhg.NetBSD.org/src/rev/19f206ac9e35
branches:  netbsd-9
changeset: 933912:19f206ac9e35
user:      martin <martin%NetBSD.org@localhost>
date:      Sun May 31 10:25:58 2020 +0000

description:
Pull up following revision(s) (requested by skrll in ticket #934):

        sys/dev/usb/usb.c: revision 1.187

Don't allow open of /dev/usb if there are no attached busses.
PR kern/55303 mutex_vector_enter,512: uninitialized lock

diffstat:

 sys/dev/usb/usb.c |  15 +++++++++++++--
 1 files changed, 13 insertions(+), 2 deletions(-)

diffs (50 lines):

diff -r 04a1d9f899e5 -r 19f206ac9e35 sys/dev/usb/usb.c
--- a/sys/dev/usb/usb.c Sun May 31 10:21:34 2020 +0000
+++ b/sys/dev/usb/usb.c Sun May 31 10:25:58 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: usb.c,v 1.179.2.2 2020/03/01 12:35:16 martin Exp $     */
+/*     $NetBSD: usb.c,v 1.179.2.3 2020/05/31 10:25:58 martin Exp $     */
 
 /*
  * Copyright (c) 1998, 2002, 2008, 2012 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: usb.c,v 1.179.2.2 2020/03/01 12:35:16 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: usb.c,v 1.179.2.3 2020/05/31 10:25:58 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -182,6 +182,11 @@
 Static void    usb_event_thread(void *);
 Static void    usb_task_thread(void *);
 
+/*
+ * Count of USB busses
+ */
+int nusbbusses = 0;
+
 #define USB_MAX_EVENTS 100
 struct usb_event_q {
        struct usb_event ue;
@@ -330,6 +335,9 @@
 
        USBHIST_FUNC(); USBHIST_CALLED(usbdebug);
 
+       /* Protected by KERNEL_LOCK */
+       nusbbusses++;
+
        sc->sc_bus->ub_usbctl = self;
        sc->sc_port.up_power = USB_MAX_POWER;
 
@@ -660,6 +668,9 @@
        int unit = minor(dev);
        struct usb_softc *sc;
 
+       if (nusbbusses == 0)
+               return ENXIO;
+
        if (unit == USB_DEV_MINOR) {
                if (usb_dev_open)
                        return EBUSY;



Home | Main Index | Thread Index | Old Index