Source-Changes-HG archive

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

[src/trunk]: src/sys/net Fix the destruction of the afdata lock



details:   https://anonhg.NetBSD.org/src/rev/19b633be0d2d
branches:  trunk
changeset: 342664:19b633be0d2d
user:      ozaki-r <ozaki-r%NetBSD.org@localhost>
date:      Mon Jan 04 09:08:38 2016 +0000

description:
Fix the destruction of the afdata lock

Pointed out by mlelstv@

diffstat:

 sys/net/if.c |  6 ++++--
 sys/net/if.h |  8 +++++---
 2 files changed, 9 insertions(+), 5 deletions(-)

diffs (70 lines):

diff -r 076ccac9ca2f -r 19b633be0d2d sys/net/if.c
--- a/sys/net/if.c      Mon Jan 04 08:24:42 2016 +0000
+++ b/sys/net/if.c      Mon Jan 04 09:08:38 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if.c,v 1.319 2015/11/20 08:10:36 ozaki-r Exp $ */
+/*     $NetBSD: if.c,v 1.320 2016/01/04 09:08:38 ozaki-r Exp $ */
 
 /*-
  * Copyright (c) 1999, 2000, 2001, 2008 The NetBSD Foundation, Inc.
@@ -90,7 +90,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if.c,v 1.319 2015/11/20 08:10:36 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if.c,v 1.320 2016/01/04 09:08:38 ozaki-r Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_inet.h"
@@ -895,6 +895,8 @@
 
        ifioctl_detach(ifp);
 
+       IF_AFDATA_LOCK_DESTROY(ifp);
+
        /*
         * remove packets that came from ifp, from software interrupt queues.
         */
diff -r 076ccac9ca2f -r 19b633be0d2d sys/net/if.h
--- a/sys/net/if.h      Mon Jan 04 08:24:42 2016 +0000
+++ b/sys/net/if.h      Mon Jan 04 09:08:38 2016 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if.h,v 1.193 2015/10/02 03:08:26 ozaki-r Exp $ */
+/*     $NetBSD: if.h,v 1.194 2016/01/04 09:08:38 ozaki-r Exp $ */
 
 /*-
  * Copyright (c) 1999, 2000, 2001 The NetBSD Foundation, Inc.
@@ -452,6 +452,8 @@
                (ifp)->if_afdata_lock = mutex_obj_alloc(MUTEX_DEFAULT, IPL_NET); \
        } while (0)
 
+#define        IF_AFDATA_LOCK_DESTROY(ifp)     mutex_obj_free((ifp)->if_afdata_lock)
+
 #define        IF_AFDATA_WLOCK(ifp)    mutex_enter((ifp)->if_afdata_lock)
 #define        IF_AFDATA_RLOCK(ifp)    mutex_enter((ifp)->if_afdata_lock)
 #define        IF_AFDATA_WUNLOCK(ifp)  mutex_exit((ifp)->if_afdata_lock)
@@ -459,7 +461,6 @@
 #define        IF_AFDATA_LOCK(ifp)     IF_AFDATA_WLOCK(ifp)
 #define        IF_AFDATA_UNLOCK(ifp)   IF_AFDATA_WUNLOCK(ifp)
 #define        IF_AFDATA_TRYLOCK(ifp)  mutex_tryenter((ifp)->if_afdata_lock)
-#define        IF_AFDATA_DESTROY(ifp)  mutex_destroy((ifp)->if_afdata_lock)
 
 #define        IF_AFDATA_LOCK_ASSERT(ifp)      \
        KASSERT(mutex_owned((ifp)->if_afdata_lock))
@@ -474,6 +475,8 @@
 #define        IF_AFDATA_LOCK_INIT(ifp)        \
        do {(ifp)->if_afdata_lock = rw_obj_alloc();} while (0)
 
+#define        IF_AFDATA_LOCK_DESTROY(ifp)     rw_obj_free((ifp)->if_afdata_lock)
+
 #define        IF_AFDATA_WLOCK(ifp)    rw_enter((ifp)->if_afdata_lock, RW_WRITER)
 #define        IF_AFDATA_RLOCK(ifp)    rw_enter((ifp)->if_afdata_lock, RW_READER)
 #define        IF_AFDATA_WUNLOCK(ifp)  rw_exit((ifp)->if_afdata_lock)
@@ -481,7 +484,6 @@
 #define        IF_AFDATA_LOCK(ifp)     IF_AFDATA_WLOCK(ifp)
 #define        IF_AFDATA_UNLOCK(ifp)   IF_AFDATA_WUNLOCK(ifp)
 #define        IF_AFDATA_TRYLOCK(ifp)  rw_tryenter((ifp)->if_afdata_lock, RW_WRITER)
-#define        IF_AFDATA_DESTROY(ifp)  rw_destroy((ifp)->if_afdata_lock)
 
 #define        IF_AFDATA_LOCK_ASSERT(ifp)      \
        KASSERT(rw_lock_held((ifp)->if_afdata_lock))



Home | Main Index | Thread Index | Old Index