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: Take IFNET_LOCK around access to if_flag...



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

description:
usbnet: Take IFNET_LOCK around access to if_flags in usbnet_detach.

This is not stable without IFNET_LOCK.  Extraneous calls to
usbnet_stop arising from this race might be harmless, but let's
render it unnecessary to even think about that.

diffstat:

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

diffs (32 lines):

diff -r c181dd01394b -r ea1795b888ed sys/dev/usb/usbnet.c
--- a/sys/dev/usb/usbnet.c      Thu Mar 03 05:46:58 2022 +0000
+++ b/sys/dev/usb/usbnet.c      Thu Mar 03 05:47:06 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: usbnet.c,v 1.46 2022/03/03 05:46:58 riastradh Exp $    */
+/*     $NetBSD: usbnet.c,v 1.47 2022/03/03 05:47:06 riastradh Exp $    */
 
 /*
  * Copyright (c) 2019 Matthew R. Green
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: usbnet.c,v 1.46 2022/03/03 05:46:58 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: usbnet.c,v 1.47 2022/03/03 05:47:06 riastradh Exp $");
 
 #include <sys/param.h>
 #include <sys/kernel.h>
@@ -1554,11 +1554,11 @@
        unp->unp_dying = true;
        mutex_exit(&unp->unp_core_lock);
 
+       IFNET_LOCK(ifp);
        if (ifp->if_flags & IFF_RUNNING) {
-               IFNET_LOCK(ifp);
                usbnet_if_stop(ifp, 1);
-               IFNET_UNLOCK(ifp);
        }
+       IFNET_UNLOCK(ifp);
 
        callout_halt(&unp->unp_stat_ch, NULL);
        usb_rem_task_wait(un->un_udev, &unp->unp_ticktask, USB_TASKQ_DRIVER,



Home | Main Index | Thread Index | Old Index