Module Name:    src
Committed By:   skrll
Date:           Fri Jul 15 06:36:21 UTC 2016

Modified Files:
        src/sys/dev/ic [nick-nhusb]: dwc_gmac.c

Log Message:
Protect sc_if_flags in dwc_gmac_ifflags_cb with the lock


To generate a diff of this commit:
cvs rdiff -u -r1.28.2.9 -r1.28.2.10 src/sys/dev/ic/dwc_gmac.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/ic/dwc_gmac.c
diff -u src/sys/dev/ic/dwc_gmac.c:1.28.2.9 src/sys/dev/ic/dwc_gmac.c:1.28.2.10
--- src/sys/dev/ic/dwc_gmac.c:1.28.2.9	Fri Jul 15 06:35:27 2016
+++ src/sys/dev/ic/dwc_gmac.c	Fri Jul 15 06:36:21 2016
@@ -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 @@ dwc_gmac_ifflags_cb(struct ethercom *ec)
 {
 	struct ifnet *ifp = &ec->ec_if;
 	struct dwc_gmac_softc *sc = ifp->if_softc;
+	int ret = 0;
+
+	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)
-		return ENETRESET;
+	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

Reply via email to