Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/usb usbnet: Assert IFNET_LOCKED on if_flags change c...



details:   https://anonhg.NetBSD.org/src/rev/ff1bab205054
branches:  trunk
changeset: 362488:ff1bab205054
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Thu Mar 03 05:47:28 2022 +0000

description:
usbnet: Assert IFNET_LOCKED on if_flags change callbacks.

- if_init
- if_stop
- ethersubr(9) ifflags_cb

diffstat:

 sys/dev/usb/usbnet.c |  10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)

diffs (45 lines):

diff -r e2776d2f8b4b -r ff1bab205054 sys/dev/usb/usbnet.c
--- a/sys/dev/usb/usbnet.c      Thu Mar 03 05:47:21 2022 +0000
+++ b/sys/dev/usb/usbnet.c      Thu Mar 03 05:47:28 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: usbnet.c,v 1.49 2022/03/03 05:47:21 riastradh Exp $    */
+/*     $NetBSD: usbnet.c,v 1.50 2022/03/03 05:47:28 riastradh Exp $    */
 
 /*
  * Copyright (c) 2019 Matthew R. Green
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: usbnet.c,v 1.49 2022/03/03 05:47:21 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: usbnet.c,v 1.50 2022/03/03 05:47:28 riastradh Exp $");
 
 #include <sys/param.h>
 #include <sys/kernel.h>
@@ -1006,6 +1006,8 @@
        struct usbnet_private * const unp = un->un_pri;
        int rv = 0;
 
+       KASSERTMSG(IFNET_LOCKED(ifp), "%s", ifp->if_xname);
+
        mutex_enter(&unp->unp_core_lock);
 
        const u_short changed = ifp->if_flags ^ unp->unp_if_flags;
@@ -1163,6 +1165,8 @@
        struct usbnet * const un = ifp->if_softc;
        struct usbnet_private * const unp = un->un_pri;
 
+       KASSERTMSG(IFNET_LOCKED(ifp), "%s", ifp->if_xname);
+
        mutex_enter(&unp->unp_core_lock);
        usbnet_stop(un, ifp, disable);
        mutex_exit(&unp->unp_core_lock);
@@ -1272,6 +1276,8 @@
        USBNETHIST_FUNC(); USBNETHIST_CALLED();
        struct usbnet * const un = ifp->if_softc;
 
+       KASSERTMSG(IFNET_LOCKED(ifp), "%s", ifp->if_xname);
+
        return uno_init(un, ifp);
 }
 



Home | Main Index | Thread Index | Old Index