Source-Changes-HG archive

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

[src/trunk]: src/sys/net On detach, destroy the mutex attach created, otherwi...



details:   https://anonhg.NetBSD.org/src/rev/87690c6c2191
branches:  trunk
changeset: 1008668:87690c6c2191
user:      christos <christos%NetBSD.org@localhost>
date:      Mon Mar 30 11:57:50 2020 +0000

description:
On detach, destroy the mutex attach created, otherwise we crash with LOCKDEBUG.
XXX: other interface drivers have this issue.

diffstat:

 sys/net/if_gif.c |  20 +++++++++-----------
 1 files changed, 9 insertions(+), 11 deletions(-)

diffs (48 lines):

diff -r e5e1a9e84823 -r 87690c6c2191 sys/net/if_gif.c
--- a/sys/net/if_gif.c  Mon Mar 30 11:38:29 2020 +0000
+++ b/sys/net/if_gif.c  Mon Mar 30 11:57:50 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_gif.c,v 1.152 2020/02/01 02:57:45 riastradh Exp $   */
+/*     $NetBSD: if_gif.c,v 1.153 2020/03/30 11:57:50 christos Exp $    */
 /*     $KAME: if_gif.c,v 1.76 2001/08/20 02:01:02 kjc Exp $    */
 
 /*
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_gif.c,v 1.152 2020/02/01 02:57:45 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_gif.c,v 1.153 2020/03/30 11:57:50 christos Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -324,22 +324,20 @@
 static int
 gifdetach(void)
 {
-       int error = 0;
 
        mutex_enter(&gif_softcs.lock);
        if (!LIST_EMPTY(&gif_softcs.list)) {
                mutex_exit(&gif_softcs.lock);
-               error = EBUSY;
+               return EBUSY;
        }
 
-       if (error == 0) {
-               psref_class_destroy(gv_psref_class);
+       psref_class_destroy(gv_psref_class);
 
-               if_clone_detach(&gif_cloner);
-               sysctl_teardown(&gif_sysctl);
-       }
-
-       return error;
+       if_clone_detach(&gif_cloner);
+       sysctl_teardown(&gif_sysctl);
+       mutex_exit(&gif_softcs.lock);
+       mutex_destroy(&gif_softcs.lock);
+       return 0;
 }
 
 static int



Home | Main Index | Thread Index | Old Index