aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--net/core/sock_diag.c24
1 files changed, 7 insertions, 17 deletions
diff --git a/net/core/sock_diag.c b/net/core/sock_diag.c
index 750f44f3aa31..a29e90cf36b7 100644
--- a/net/core/sock_diag.c
+++ b/net/core/sock_diag.c
@@ -97,21 +97,6 @@ void sock_diag_unregister(const struct sock_diag_handler *hnld)
97} 97}
98EXPORT_SYMBOL_GPL(sock_diag_unregister); 98EXPORT_SYMBOL_GPL(sock_diag_unregister);
99 99
100static const inline struct sock_diag_handler *sock_diag_lock_handler(int family)
101{
102 if (sock_diag_handlers[family] == NULL)
103 request_module("net-pf-%d-proto-%d-type-%d", PF_NETLINK,
104 NETLINK_SOCK_DIAG, family);
105
106 mutex_lock(&sock_diag_table_mutex);
107 return sock_diag_handlers[family];
108}
109
110static inline void sock_diag_unlock_handler(const struct sock_diag_handler *h)
111{
112 mutex_unlock(&sock_diag_table_mutex);
113}
114
115static int __sock_diag_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh) 100static int __sock_diag_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
116{ 101{
117 int err; 102 int err;
@@ -124,12 +109,17 @@ static int __sock_diag_rcv_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
124 if (req->sdiag_family >= AF_MAX) 109 if (req->sdiag_family >= AF_MAX)
125 return -EINVAL; 110 return -EINVAL;
126 111
127 hndl = sock_diag_lock_handler(req->sdiag_family); 112 if (sock_diag_handlers[req->sdiag_family] == NULL)
113 request_module("net-pf-%d-proto-%d-type-%d", PF_NETLINK,
114 NETLINK_SOCK_DIAG, req->sdiag_family);
115
116 mutex_lock(&sock_diag_table_mutex);
117 hndl = sock_diag_handlers[req->sdiag_family];
128 if (hndl == NULL) 118 if (hndl == NULL)
129 err = -ENOENT; 119 err = -ENOENT;
130 else 120 else
131 err = hndl->dump(skb, nlh); 121 err = hndl->dump(skb, nlh);
132 sock_diag_unlock_handler(hndl); 122 mutex_unlock(&sock_diag_table_mutex);
133 123
134 return err; 124 return err;
135} 125}