Don't allow open of /dev/usb if there are no attached busses.
PR kern/55303 mutex_vector_enter,512: uninitialized lock
This commit is contained in:
parent
4000f090fb
commit
f6400f295e
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: usb.c,v 1.186 2020/05/26 19:55:43 skrll Exp $ */
|
||||
/* $NetBSD: usb.c,v 1.187 2020/05/27 07:17:45 skrll 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.186 2020/05/26 19:55:43 skrll Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: usb.c,v 1.187 2020/05/27 07:17:45 skrll Exp $");
|
||||
|
||||
#ifdef _KERNEL_OPT
|
||||
#include "opt_usb.h"
|
||||
@ -232,6 +232,11 @@ Static void usb_create_event_thread(device_t);
|
||||
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;
|
||||
@ -378,6 +383,9 @@ usb_doattach(device_t self)
|
||||
|
||||
USBHIST_FUNC(); USBHIST_CALLED(usbdebug);
|
||||
|
||||
/* Protected by KERNEL_LOCK */
|
||||
nusbbusses++;
|
||||
|
||||
sc->sc_bus->ub_usbctl = self;
|
||||
sc->sc_port.up_power = USB_MAX_POWER;
|
||||
|
||||
@ -719,6 +727,9 @@ usbopen(dev_t dev, int flag, int mode, struct lwp *l)
|
||||
int unit = minor(dev);
|
||||
struct usb_softc *sc;
|
||||
|
||||
if (nusbbusses == 0)
|
||||
return ENXIO;
|
||||
|
||||
if (unit == USB_DEV_MINOR) {
|
||||
if (usb_dev_open)
|
||||
return EBUSY;
|
||||
|
Loading…
Reference in New Issue
Block a user