Module Name:    src
Committed By:   riastradh
Date:           Thu Mar  3 05:48:30 UTC 2022

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

Log Message:
usbnet: Assert IFNET_LOCKED in usbnet_media_upd.

This ensures, if the device is being initialized or stopped,
usbnet_media_upd will not run until it's done, so the reset sequence
has exclusive access to the device registers used by mii.


To generate a diff of this commit:
cvs rdiff -u -r1.56 -r1.57 src/sys/dev/usb/usbnet.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/usbnet.c
diff -u src/sys/dev/usb/usbnet.c:1.56 src/sys/dev/usb/usbnet.c:1.57
--- src/sys/dev/usb/usbnet.c:1.56	Thu Mar  3 05:48:22 2022
+++ src/sys/dev/usb/usbnet.c	Thu Mar  3 05:48:30 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: usbnet.c,v 1.56 2022/03/03 05:48:22 riastradh Exp $	*/
+/*	$NetBSD: usbnet.c,v 1.57 2022/03/03 05:48:30 riastradh Exp $	*/
 
 /*
  * Copyright (c) 2019 Matthew R. Green
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: usbnet.c,v 1.56 2022/03/03 05:48:22 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: usbnet.c,v 1.57 2022/03/03 05:48:30 riastradh Exp $");
 
 #include <sys/param.h>
 #include <sys/kernel.h>
@@ -983,6 +983,9 @@ usbnet_media_upd(struct ifnet *ifp)
 	/* ifmedia layer ensures core_lock is held. */
 	usbnet_isowned_core(un);
 
+	/* ifmedia changes only with IFNET_LOCK held.  */
+	KASSERTMSG(IFNET_LOCKED(ifp), "%s", ifp->if_xname);
+
 	if (unp->unp_dying)
 		return EIO;
 

Reply via email to