]> git.saurik.com Git - apple/xnu.git/blobdiff - bsd/net/rtsock.c
xnu-792.2.4.tar.gz
[apple/xnu.git] / bsd / net / rtsock.c
index 54abd75f0de4dbba884d9006128d76cf353ac1bf..c919f5537e6817b0aa8b83ee029b24349587df36 100644 (file)
@@ -1361,17 +1361,18 @@ sysctl_rtsock SYSCTL_HANDLER_ARGS
        w.w_arg = name[2];
        w.w_req = req;
 
-       lck_mtx_lock(rt_mtx);
        switch (w.w_op) {
 
        case NET_RT_DUMP:
        case NET_RT_DUMP2:
        case NET_RT_FLAGS:
+               lck_mtx_lock(rt_mtx);
                for (i = 1; i <= AF_MAX; i++)
                        if ((rnh = rt_tables[i]) && (af == 0 || af == i) &&
                            (error = rnh->rnh_walktree(rnh,
                                                        sysctl_dumpentry, &w)))
                                break;
+               lck_mtx_unlock(rt_mtx);
                break;
        case NET_RT_IFLIST:
                error = sysctl_iflist(af, &w);
@@ -1386,7 +1387,6 @@ sysctl_rtsock SYSCTL_HANDLER_ARGS
                error = sysctl_rttrash(req);
                break;
        }
-       lck_mtx_unlock(rt_mtx);
        if (w.w_tmem)
                FREE(w.w_tmem, M_RTABLE);
        return (error);