diff options
Diffstat (limited to 'net/bluetooth/af_bluetooth.c')
-rw-r--r-- | net/bluetooth/af_bluetooth.c | 50 |
1 files changed, 25 insertions, 25 deletions
diff --git a/net/bluetooth/af_bluetooth.c b/net/bluetooth/af_bluetooth.c index 8f9431a12c6f..744ed3f07ef3 100644 --- a/net/bluetooth/af_bluetooth.c +++ b/net/bluetooth/af_bluetooth.c | |||
@@ -41,18 +41,14 @@ | |||
41 | 41 | ||
42 | #include <net/bluetooth/bluetooth.h> | 42 | #include <net/bluetooth/bluetooth.h> |
43 | 43 | ||
44 | #ifndef CONFIG_BT_SOCK_DEBUG | 44 | #define VERSION "2.14" |
45 | #undef BT_DBG | ||
46 | #define BT_DBG(D...) | ||
47 | #endif | ||
48 | |||
49 | #define VERSION "2.13" | ||
50 | 45 | ||
51 | /* Bluetooth sockets */ | 46 | /* Bluetooth sockets */ |
52 | #define BT_MAX_PROTO 8 | 47 | #define BT_MAX_PROTO 8 |
53 | static struct net_proto_family *bt_proto[BT_MAX_PROTO]; | 48 | static struct net_proto_family *bt_proto[BT_MAX_PROTO]; |
49 | static DEFINE_RWLOCK(bt_proto_lock); | ||
54 | 50 | ||
55 | static struct lock_class_key bt_slock_key[BT_MAX_PROTO]; | 51 | #ifdef CONFIG_DEBUG_LOCK_ALLOC |
56 | static struct lock_class_key bt_lock_key[BT_MAX_PROTO]; | 52 | static struct lock_class_key bt_lock_key[BT_MAX_PROTO]; |
57 | static const char *bt_key_strings[BT_MAX_PROTO] = { | 53 | static const char *bt_key_strings[BT_MAX_PROTO] = { |
58 | "sk_lock-AF_BLUETOOTH-BTPROTO_L2CAP", | 54 | "sk_lock-AF_BLUETOOTH-BTPROTO_L2CAP", |
@@ -65,6 +61,7 @@ static const char *bt_key_strings[BT_MAX_PROTO] = { | |||
65 | "sk_lock-AF_BLUETOOTH-BTPROTO_AVDTP", | 61 | "sk_lock-AF_BLUETOOTH-BTPROTO_AVDTP", |
66 | }; | 62 | }; |
67 | 63 | ||
64 | static struct lock_class_key bt_slock_key[BT_MAX_PROTO]; | ||
68 | static const char *bt_slock_key_strings[BT_MAX_PROTO] = { | 65 | static const char *bt_slock_key_strings[BT_MAX_PROTO] = { |
69 | "slock-AF_BLUETOOTH-BTPROTO_L2CAP", | 66 | "slock-AF_BLUETOOTH-BTPROTO_L2CAP", |
70 | "slock-AF_BLUETOOTH-BTPROTO_HCI", | 67 | "slock-AF_BLUETOOTH-BTPROTO_HCI", |
@@ -75,7 +72,25 @@ static const char *bt_slock_key_strings[BT_MAX_PROTO] = { | |||
75 | "slock-AF_BLUETOOTH-BTPROTO_HIDP", | 72 | "slock-AF_BLUETOOTH-BTPROTO_HIDP", |
76 | "slock-AF_BLUETOOTH-BTPROTO_AVDTP", | 73 | "slock-AF_BLUETOOTH-BTPROTO_AVDTP", |
77 | }; | 74 | }; |
78 | static DEFINE_RWLOCK(bt_proto_lock); | 75 | |
76 | static inline void bt_sock_reclassify_lock(struct socket *sock, int proto) | ||
77 | { | ||
78 | struct sock *sk = sock->sk; | ||
79 | |||
80 | if (!sk) | ||
81 | return; | ||
82 | |||
83 | BUG_ON(sock_owned_by_user(sk)); | ||
84 | |||
85 | sock_lock_init_class_and_name(sk, | ||
86 | bt_slock_key_strings[proto], &bt_slock_key[proto], | ||
87 | bt_key_strings[proto], &bt_lock_key[proto]); | ||
88 | } | ||
89 | #else | ||
90 | static inline void bt_sock_reclassify_lock(struct socket *sock, int proto) | ||
91 | { | ||
92 | } | ||
93 | #endif | ||
79 | 94 | ||
80 | int bt_sock_register(int proto, struct net_proto_family *ops) | 95 | int bt_sock_register(int proto, struct net_proto_family *ops) |
81 | { | 96 | { |
@@ -117,21 +132,6 @@ int bt_sock_unregister(int proto) | |||
117 | } | 132 | } |
118 | EXPORT_SYMBOL(bt_sock_unregister); | 133 | EXPORT_SYMBOL(bt_sock_unregister); |
119 | 134 | ||
120 | static void bt_reclassify_sock_lock(struct socket *sock, int proto) | ||
121 | { | ||
122 | struct sock *sk = sock->sk; | ||
123 | |||
124 | if (!sk) | ||
125 | return; | ||
126 | BUG_ON(sock_owned_by_user(sk)); | ||
127 | |||
128 | sock_lock_init_class_and_name(sk, | ||
129 | bt_slock_key_strings[proto], | ||
130 | &bt_slock_key[proto], | ||
131 | bt_key_strings[proto], | ||
132 | &bt_lock_key[proto]); | ||
133 | } | ||
134 | |||
135 | static int bt_sock_create(struct net *net, struct socket *sock, int proto) | 135 | static int bt_sock_create(struct net *net, struct socket *sock, int proto) |
136 | { | 136 | { |
137 | int err; | 137 | int err; |
@@ -151,7 +151,7 @@ static int bt_sock_create(struct net *net, struct socket *sock, int proto) | |||
151 | 151 | ||
152 | if (bt_proto[proto] && try_module_get(bt_proto[proto]->owner)) { | 152 | if (bt_proto[proto] && try_module_get(bt_proto[proto]->owner)) { |
153 | err = bt_proto[proto]->create(net, sock, proto); | 153 | err = bt_proto[proto]->create(net, sock, proto); |
154 | bt_reclassify_sock_lock(sock, proto); | 154 | bt_sock_reclassify_lock(sock, proto); |
155 | module_put(bt_proto[proto]->owner); | 155 | module_put(bt_proto[proto]->owner); |
156 | } | 156 | } |
157 | 157 | ||
@@ -240,7 +240,7 @@ int bt_sock_recvmsg(struct kiocb *iocb, struct socket *sock, | |||
240 | size_t copied; | 240 | size_t copied; |
241 | int err; | 241 | int err; |
242 | 242 | ||
243 | BT_DBG("sock %p sk %p len %d", sock, sk, len); | 243 | BT_DBG("sock %p sk %p len %zu", sock, sk, len); |
244 | 244 | ||
245 | if (flags & (MSG_OOB)) | 245 | if (flags & (MSG_OOB)) |
246 | return -EOPNOTSUPP; | 246 | return -EOPNOTSUPP; |