Module Name:    src
Committed By:   mlelstv
Date:           Mon Apr 30 05:04:34 UTC 2018

Modified Files:
        src/sys/dev/usb: usb_subr.c

Log Message:
add missing KERNEL_LOCK protection around autoconf calls.

Also replace NULL argument with curlwp for style.


To generate a diff of this commit:
cvs rdiff -u -r1.223 -r1.224 src/sys/dev/usb/usb_subr.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/usb/usb_subr.c
diff -u src/sys/dev/usb/usb_subr.c:1.223 src/sys/dev/usb/usb_subr.c:1.224
--- src/sys/dev/usb/usb_subr.c:1.223	Tue Dec 26 18:44:52 2017
+++ src/sys/dev/usb/usb_subr.c	Mon Apr 30 05:04:34 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: usb_subr.c,v 1.223 2017/12/26 18:44:52 khorben Exp $	*/
+/*	$NetBSD: usb_subr.c,v 1.224 2018/04/30 05:04:34 mlelstv Exp $	*/
 /*	$FreeBSD: src/sys/dev/usb/usb_subr.c,v 1.18 1999/11/17 22:33:47 n_hibma Exp $	*/
 
 /*
@@ -32,7 +32,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: usb_subr.c,v 1.223 2017/12/26 18:44:52 khorben Exp $");
+__KERNEL_RCSID(0, "$NetBSD: usb_subr.c,v 1.224 2018/04/30 05:04:34 mlelstv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -858,7 +858,9 @@ usbd_attach_roothub(device_t parent, str
 	uaa.uaa_subclass = dd->bDeviceSubClass;
 	uaa.uaa_proto = dd->bDeviceProtocol;
 
+	KERNEL_LOCK(1, curlwp);
 	dv = config_found_ia(parent, "usbroothubif", &uaa, 0);
+	KERNEL_UNLOCK_ONE(curlwp);
 	if (dv) {
 		dev->ud_subdevs = kmem_alloc(sizeof(dv), KM_SLEEP);
 		dev->ud_subdevs[0] = dv;
@@ -903,10 +905,10 @@ usbd_attachwholedevice(device_t parent, 
 	dlocs[USBDEVIFCF_CONFIGURATION] = -1;
 	dlocs[USBDEVIFCF_INTERFACE] = -1;
 
-	KERNEL_LOCK(1, NULL);
+	KERNEL_LOCK(1, curlwp);
 	dv = config_found_sm_loc(parent, "usbdevif", dlocs, &uaa, usbd_print,
 				 config_stdsubmatch);
-	KERNEL_UNLOCK_ONE(NULL);
+	KERNEL_UNLOCK_ONE(curlwp);
 	if (dv) {
 		dev->ud_subdevs = kmem_alloc(sizeof(dv), KM_SLEEP);
 		dev->ud_subdevs[0] = dv;
@@ -980,10 +982,10 @@ usbd_attachinterfaces(device_t parent, s
 			    loc != uiaa.uiaa_ifaceno)
 				continue;
 		}
-		KERNEL_LOCK(1, NULL);
+		KERNEL_LOCK(1, curlwp);
 		dv = config_found_sm_loc(parent, "usbifif", ilocs, &uiaa,
 					 usbd_ifprint, config_stdsubmatch);
-		KERNEL_UNLOCK_ONE(NULL);
+		KERNEL_UNLOCK_ONE(curlwp);
 		if (!dv)
 			continue;
 
@@ -1727,7 +1729,10 @@ usb_disconnect_port(struct usbd_port *up
 				continue;
 			strlcpy(subdevname, device_xname(subdev),
 			    sizeof(subdevname));
-			if ((rc = config_detach(subdev, flags)) != 0)
+			KERNEL_LOCK(1, curlwp);
+			rc = config_detach(subdev, flags);
+			KERNEL_UNLOCK_ONE(curlwp);
+			if (rc != 0)
 				return rc;
 			printf("%s: at %s", subdevname, hubname);
 			if (up->up_portno != 0)

Reply via email to