Source-Changes-HG archive

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

[src/trunk]: src/sys/net fix locking against myself in module autoload; modul...



details:   https://anonhg.NetBSD.org/src/rev/25958bf1f14d
branches:  trunk
changeset: 350863:25958bf1f14d
user:      christos <christos%NetBSD.org@localhost>
date:      Wed Jan 25 03:04:21 2017 +0000

description:
fix locking against myself in module autoload; module autoload calls
if_clone_attach which takes the lock again.

diffstat:

 sys/net/if.c |  13 +++++++++----
 1 files changed, 9 insertions(+), 4 deletions(-)

diffs (34 lines):

diff -r fab742036974 -r 25958bf1f14d sys/net/if.c
--- a/sys/net/if.c      Wed Jan 25 01:04:23 2017 +0000
+++ b/sys/net/if.c      Wed Jan 25 03:04:21 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if.c,v 1.374 2017/01/24 07:58:58 ozaki-r Exp $ */
+/*     $NetBSD: if.c,v 1.375 2017/01/25 03:04:21 christos 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.374 2017/01/24 07:58:58 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if.c,v 1.375 2017/01/25 03:04:21 christos Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_inet.h"
@@ -1619,8 +1619,13 @@
        }
 
        if (ifc == NULL) {
-               if (*ifname == '\0' ||
-                   module_autoload(ifname, MODULE_CLASS_DRIVER))
+               int error;
+               if (*ifname == '\0')
+                       return NULL;
+               mutex_exit(&if_clone_mtx);
+               error = module_autoload(ifname, MODULE_CLASS_DRIVER);
+               mutex_enter(&if_clone_mtx);
+               if (error)
                        return NULL;
                *ifname = '\0';
                goto again;



Home | Main Index | Thread Index | Old Index