Source-Changes-HG archive

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

[src/trunk]: src/sys/dev Simplify and fix the unload to destroy the mutex. To...



details:   https://anonhg.NetBSD.org/src/rev/c7909fc66a70
branches:  trunk
changeset: 342726:c7909fc66a70
user:      christos <christos%NetBSD.org@localhost>
date:      Wed Jan 06 18:06:38 2016 +0000

description:
Simplify and fix the unload to destroy the mutex. To reproduce, configure
a kernel with LOCKDEBUG make clockctl a module:

    /etc/rc.d/ntpd stop
    modunload clockctl
    /etc/rc.d/ntpd start
    boom.

diffstat:

 sys/dev/clockctl.c |  23 ++++++-----------------
 1 files changed, 6 insertions(+), 17 deletions(-)

diffs (73 lines):

diff -r 5464a9723a13 -r c7909fc66a70 sys/dev/clockctl.c
--- a/sys/dev/clockctl.c        Wed Jan 06 17:41:36 2016 +0000
+++ b/sys/dev/clockctl.c        Wed Jan 06 18:06:38 2016 +0000
@@ -1,4 +1,4 @@
-/*      $NetBSD: clockctl.c,v 1.33 2015/12/07 03:25:57 pgoyette Exp $ */
+/*      $NetBSD: clockctl.c,v 1.34 2016/01/06 18:06:38 christos Exp $ */
 
 /*-
  * Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: clockctl.c,v 1.33 2015/12/07 03:25:57 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: clockctl.c,v 1.34 2016/01/06 18:06:38 christos Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ntp.h"
@@ -52,7 +52,6 @@
 #include <sys/kauth.h>
 #include <sys/module.h>
 #include <sys/mutex.h>
-#include <sys/once.h>
 
 #include <sys/clockctl.h>
 #ifdef COMPAT_50
@@ -63,8 +62,6 @@
 kmutex_t clockctl_mtx;
 int clockctl_refcnt;
 
-ONCE_DECL(clockctl_once);
-
 #include "ioconf.h"
 
 dev_type_ioctl(clockctlioctl);
@@ -151,15 +148,6 @@
        return 0;
 }
 
-int
-clockctl_init(void)
-{
-
-       mutex_init(&clockctl_mtx, MUTEX_DEFAULT, IPL_NONE);
-       clockctl_refcnt = 0;
-       return 0;
-}
-
 MODULE(MODULE_CLASS_DRIVER, clockctl, NULL);
 
 int
@@ -174,7 +162,7 @@
 
        switch (cmd) {
        case MODULE_CMD_INIT:
-               RUN_ONCE(&clockctl_once, clockctl_init);
+               mutex_init(&clockctl_mtx, MUTEX_DEFAULT, IPL_NONE);
 
                clockctl_listener = kauth_listen_scope(KAUTH_SCOPE_SYSTEM,
                    clockctl_listener_cb, NULL);
@@ -200,9 +188,10 @@
 #endif
                mutex_exit(&clockctl_mtx);
 
-               if (error == 0)
+               if (error == 0) {
                        kauth_unlisten_scope(clockctl_listener);
-
+                       mutex_destroy(&clockctl_mtx);
+               }
                break;
 
        default:



Home | Main Index | Thread Index | Old Index