Source-Changes-HG archive

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

[src/nick-nhusb]: src/sys/dev/ic Protect sc_if_flags in dwc_gmac_ifflags_cb w...



details:   https://anonhg.NetBSD.org/src/rev/343c46d73527
branches:  nick-nhusb
changeset: 334533:343c46d73527
user:      skrll <skrll%NetBSD.org@localhost>
date:      Fri Jul 15 06:36:21 2016 +0000

description:
Protect sc_if_flags in dwc_gmac_ifflags_cb with the lock

diffstat:

 sys/dev/ic/dwc_gmac.c |  23 +++++++++++++++--------
 1 files changed, 15 insertions(+), 8 deletions(-)

diffs (48 lines):

diff -r 64d34f37608f -r 343c46d73527 sys/dev/ic/dwc_gmac.c
--- a/sys/dev/ic/dwc_gmac.c     Fri Jul 15 06:35:27 2016 +0000
+++ b/sys/dev/ic/dwc_gmac.c     Fri Jul 15 06:36:21 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: dwc_gmac.c,v 1.28.2.9 2016/07/15 06:35:27 skrll Exp $ */
+/* $NetBSD: dwc_gmac.c,v 1.28.2.10 2016/07/15 06:36:21 skrll Exp $ */
 
 /*-
  * Copyright (c) 2013, 2014 The NetBSD Foundation, Inc.
@@ -41,7 +41,7 @@
 
 #include <sys/cdefs.h>
 
-__KERNEL_RCSID(1, "$NetBSD: dwc_gmac.c,v 1.28.2.9 2016/07/15 06:35:27 skrll Exp $");
+__KERNEL_RCSID(1, "$NetBSD: dwc_gmac.c,v 1.28.2.10 2016/07/15 06:36:21 skrll Exp $");
 
 /* #define     DWC_GMAC_DEBUG  1 */
 
@@ -997,16 +997,23 @@
 {
        struct ifnet *ifp = &ec->ec_if;
        struct dwc_gmac_softc *sc = ifp->if_softc;
-       int change = ifp->if_flags ^ sc->sc_if_flags;
+       int ret = 0;
 
-       if ((change & ~(IFF_CANTCHANGE|IFF_DEBUG)) != 0)
-               return ENETRESET;
+       mutex_enter(sc->sc_lock);
+       int change = ifp->if_flags ^ sc->sc_if_flags;
+       sc->sc_if_flags = ifp->if_flags;
+
+       if ((change & ~(IFF_CANTCHANGE|IFF_DEBUG)) != 0) {
+               ret = ENETRESET;
+               goto out;
+       }
        if ((change & IFF_PROMISC) != 0) {
-               mutex_enter(sc->sc_lock);
                dwc_gmac_setmulti(sc);
-               mutex_exit(sc->sc_lock);
        }
-       return 0;
+out:
+       mutex_exit(sc->sc_lock);
+
+       return ret;
 }
 
 static int



Home | Main Index | Thread Index | Old Index