aboutsummaryrefslogtreecommitdiffstats
path: root/net/bluetooth
diff options
context:
space:
mode:
Diffstat (limited to 'net/bluetooth')
-rw-r--r--net/bluetooth/bnep/bnep.h4
-rw-r--r--net/bluetooth/bnep/core.c28
-rw-r--r--net/bluetooth/bnep/netdev.c11
-rw-r--r--net/bluetooth/l2cap.c4
-rw-r--r--net/bluetooth/rfcomm/core.c18
5 files changed, 33 insertions, 32 deletions
diff --git a/net/bluetooth/bnep/bnep.h b/net/bluetooth/bnep/bnep.h
index bbb1ed7097a9..0b6cd0e2528d 100644
--- a/net/bluetooth/bnep/bnep.h
+++ b/net/bluetooth/bnep/bnep.h
@@ -95,14 +95,14 @@ struct bnep_setup_conn_req {
95struct bnep_set_filter_req { 95struct bnep_set_filter_req {
96 __u8 type; 96 __u8 type;
97 __u8 ctrl; 97 __u8 ctrl;
98 __u16 len; 98 __be16 len;
99 __u8 list[0]; 99 __u8 list[0];
100} __attribute__((packed)); 100} __attribute__((packed));
101 101
102struct bnep_control_rsp { 102struct bnep_control_rsp {
103 __u8 type; 103 __u8 type;
104 __u8 ctrl; 104 __u8 ctrl;
105 __u16 resp; 105 __be16 resp;
106} __attribute__((packed)); 106} __attribute__((packed));
107 107
108struct bnep_ext_hdr { 108struct bnep_ext_hdr {
diff --git a/net/bluetooth/bnep/core.c b/net/bluetooth/bnep/core.c
index 4d3424c2421c..7ba6470dc507 100644
--- a/net/bluetooth/bnep/core.c
+++ b/net/bluetooth/bnep/core.c
@@ -117,18 +117,18 @@ static int bnep_send_rsp(struct bnep_session *s, u8 ctrl, u16 resp)
117static inline void bnep_set_default_proto_filter(struct bnep_session *s) 117static inline void bnep_set_default_proto_filter(struct bnep_session *s)
118{ 118{
119 /* (IPv4, ARP) */ 119 /* (IPv4, ARP) */
120 s->proto_filter[0].start = htons(0x0800); 120 s->proto_filter[0].start = ETH_P_IP;
121 s->proto_filter[0].end = htons(0x0806); 121 s->proto_filter[0].end = ETH_P_ARP;
122 /* (RARP, AppleTalk) */ 122 /* (RARP, AppleTalk) */
123 s->proto_filter[1].start = htons(0x8035); 123 s->proto_filter[1].start = ETH_P_RARP;
124 s->proto_filter[1].end = htons(0x80F3); 124 s->proto_filter[1].end = ETH_P_AARP;
125 /* (IPX, IPv6) */ 125 /* (IPX, IPv6) */
126 s->proto_filter[2].start = htons(0x8137); 126 s->proto_filter[2].start = ETH_P_IPX;
127 s->proto_filter[2].end = htons(0x86DD); 127 s->proto_filter[2].end = ETH_P_IPV6;
128} 128}
129#endif 129#endif
130 130
131static int bnep_ctrl_set_netfilter(struct bnep_session *s, u16 *data, int len) 131static int bnep_ctrl_set_netfilter(struct bnep_session *s, __be16 *data, int len)
132{ 132{
133 int n; 133 int n;
134 134
@@ -150,8 +150,8 @@ static int bnep_ctrl_set_netfilter(struct bnep_session *s, u16 *data, int len)
150 int i; 150 int i;
151 151
152 for (i = 0; i < n; i++) { 152 for (i = 0; i < n; i++) {
153 f[i].start = get_unaligned(data++); 153 f[i].start = ntohs(get_unaligned(data++));
154 f[i].end = get_unaligned(data++); 154 f[i].end = ntohs(get_unaligned(data++));
155 155
156 BT_DBG("proto filter start %d end %d", 156 BT_DBG("proto filter start %d end %d",
157 f[i].start, f[i].end); 157 f[i].start, f[i].end);
@@ -180,7 +180,7 @@ static int bnep_ctrl_set_mcfilter(struct bnep_session *s, u8 *data, int len)
180 if (len < 2) 180 if (len < 2)
181 return -EILSEQ; 181 return -EILSEQ;
182 182
183 n = ntohs(get_unaligned((u16 *) data)); 183 n = ntohs(get_unaligned((__be16 *) data));
184 data += 2; len -= 2; 184 data += 2; len -= 2;
185 185
186 if (len < n) 186 if (len < n)
@@ -332,7 +332,7 @@ static inline int bnep_rx_frame(struct bnep_session *s, struct sk_buff *skb)
332 if (!skb_pull(skb, __bnep_rx_hlen[type & BNEP_TYPE_MASK])) 332 if (!skb_pull(skb, __bnep_rx_hlen[type & BNEP_TYPE_MASK]))
333 goto badframe; 333 goto badframe;
334 334
335 s->eh.h_proto = get_unaligned((u16 *) (skb->data - 2)); 335 s->eh.h_proto = get_unaligned((__be16 *) (skb->data - 2));
336 336
337 if (type & BNEP_EXT_HEADER) { 337 if (type & BNEP_EXT_HEADER) {
338 if (bnep_rx_extension(s, skb) < 0) 338 if (bnep_rx_extension(s, skb) < 0)
@@ -343,7 +343,7 @@ static inline int bnep_rx_frame(struct bnep_session *s, struct sk_buff *skb)
343 if (ntohs(s->eh.h_proto) == 0x8100) { 343 if (ntohs(s->eh.h_proto) == 0x8100) {
344 if (!skb_pull(skb, 4)) 344 if (!skb_pull(skb, 4))
345 goto badframe; 345 goto badframe;
346 s->eh.h_proto = get_unaligned((u16 *) (skb->data - 2)); 346 s->eh.h_proto = get_unaligned((__be16 *) (skb->data - 2));
347 } 347 }
348 348
349 /* We have to alloc new skb and copy data here :(. Because original skb 349 /* We have to alloc new skb and copy data here :(. Because original skb
@@ -365,7 +365,7 @@ static inline int bnep_rx_frame(struct bnep_session *s, struct sk_buff *skb)
365 case BNEP_COMPRESSED_SRC_ONLY: 365 case BNEP_COMPRESSED_SRC_ONLY:
366 memcpy(__skb_put(nskb, ETH_ALEN), s->eh.h_dest, ETH_ALEN); 366 memcpy(__skb_put(nskb, ETH_ALEN), s->eh.h_dest, ETH_ALEN);
367 memcpy(__skb_put(nskb, ETH_ALEN), skb->mac.raw, ETH_ALEN); 367 memcpy(__skb_put(nskb, ETH_ALEN), skb->mac.raw, ETH_ALEN);
368 put_unaligned(s->eh.h_proto, (u16 *) __skb_put(nskb, 2)); 368 put_unaligned(s->eh.h_proto, (__be16 *) __skb_put(nskb, 2));
369 break; 369 break;
370 370
371 case BNEP_COMPRESSED_DST_ONLY: 371 case BNEP_COMPRESSED_DST_ONLY:
@@ -375,7 +375,7 @@ static inline int bnep_rx_frame(struct bnep_session *s, struct sk_buff *skb)
375 375
376 case BNEP_GENERAL: 376 case BNEP_GENERAL:
377 memcpy(__skb_put(nskb, ETH_ALEN * 2), skb->mac.raw, ETH_ALEN * 2); 377 memcpy(__skb_put(nskb, ETH_ALEN * 2), skb->mac.raw, ETH_ALEN * 2);
378 put_unaligned(s->eh.h_proto, (u16 *) __skb_put(nskb, 2)); 378 put_unaligned(s->eh.h_proto, (__be16 *) __skb_put(nskb, 2));
379 break; 379 break;
380 } 380 }
381 381
diff --git a/net/bluetooth/bnep/netdev.c b/net/bluetooth/bnep/netdev.c
index 7f7b27db6a8f..67a002a9751a 100644
--- a/net/bluetooth/bnep/netdev.c
+++ b/net/bluetooth/bnep/netdev.c
@@ -158,14 +158,15 @@ static inline int bnep_net_mc_filter(struct sk_buff *skb, struct bnep_session *s
158static inline u16 bnep_net_eth_proto(struct sk_buff *skb) 158static inline u16 bnep_net_eth_proto(struct sk_buff *skb)
159{ 159{
160 struct ethhdr *eh = (void *) skb->data; 160 struct ethhdr *eh = (void *) skb->data;
161 u16 proto = ntohs(eh->h_proto);
161 162
162 if (ntohs(eh->h_proto) >= 1536) 163 if (proto >= 1536)
163 return eh->h_proto; 164 return proto;
164 165
165 if (get_unaligned((u16 *) skb->data) == 0xFFFF) 166 if (get_unaligned((__be16 *) skb->data) == htons(0xFFFF))
166 return htons(ETH_P_802_3); 167 return ETH_P_802_3;
167 168
168 return htons(ETH_P_802_2); 169 return ETH_P_802_2;
169} 170}
170 171
171static inline int bnep_net_proto_filter(struct sk_buff *skb, struct bnep_session *s) 172static inline int bnep_net_proto_filter(struct sk_buff *skb, struct bnep_session *s)
diff --git a/net/bluetooth/l2cap.c b/net/bluetooth/l2cap.c
index bbf78e6a7bc3..29a8fa4d3728 100644
--- a/net/bluetooth/l2cap.c
+++ b/net/bluetooth/l2cap.c
@@ -770,7 +770,7 @@ static int l2cap_sock_accept(struct socket *sock, struct socket *newsock, int fl
770 long timeo; 770 long timeo;
771 int err = 0; 771 int err = 0;
772 772
773 lock_sock(sk); 773 lock_sock_nested(sk, SINGLE_DEPTH_NESTING);
774 774
775 if (sk->sk_state != BT_LISTEN) { 775 if (sk->sk_state != BT_LISTEN) {
776 err = -EBADFD; 776 err = -EBADFD;
@@ -792,7 +792,7 @@ static int l2cap_sock_accept(struct socket *sock, struct socket *newsock, int fl
792 792
793 release_sock(sk); 793 release_sock(sk);
794 timeo = schedule_timeout(timeo); 794 timeo = schedule_timeout(timeo);
795 lock_sock(sk); 795 lock_sock_nested(sk, SINGLE_DEPTH_NESTING);
796 796
797 if (sk->sk_state != BT_LISTEN) { 797 if (sk->sk_state != BT_LISTEN) {
798 err = -EBADFD; 798 err = -EBADFD;
diff --git a/net/bluetooth/rfcomm/core.c b/net/bluetooth/rfcomm/core.c
index ddc4e9d5963e..278c8676906a 100644
--- a/net/bluetooth/rfcomm/core.c
+++ b/net/bluetooth/rfcomm/core.c
@@ -854,7 +854,7 @@ int rfcomm_send_rpn(struct rfcomm_session *s, int cr, u8 dlci,
854 rpn->flow_ctrl = flow_ctrl_settings; 854 rpn->flow_ctrl = flow_ctrl_settings;
855 rpn->xon_char = xon_char; 855 rpn->xon_char = xon_char;
856 rpn->xoff_char = xoff_char; 856 rpn->xoff_char = xoff_char;
857 rpn->param_mask = param_mask; 857 rpn->param_mask = cpu_to_le16(param_mask);
858 858
859 *ptr = __fcs(buf); ptr++; 859 *ptr = __fcs(buf); ptr++;
860 860
@@ -1018,7 +1018,7 @@ static void rfcomm_make_uih(struct sk_buff *skb, u8 addr)
1018 1018
1019 if (len > 127) { 1019 if (len > 127) {
1020 hdr = (void *) skb_push(skb, 4); 1020 hdr = (void *) skb_push(skb, 4);
1021 put_unaligned(htobs(__len16(len)), (u16 *) &hdr->len); 1021 put_unaligned(htobs(__len16(len)), (__le16 *) &hdr->len);
1022 } else { 1022 } else {
1023 hdr = (void *) skb_push(skb, 3); 1023 hdr = (void *) skb_push(skb, 3);
1024 hdr->len = __len8(len); 1024 hdr->len = __len8(len);
@@ -1343,7 +1343,7 @@ static int rfcomm_recv_rpn(struct rfcomm_session *s, int cr, int len, struct sk_
1343 /* Check for sane values, ignore/accept bit_rate, 8 bits, 1 stop bit, 1343 /* Check for sane values, ignore/accept bit_rate, 8 bits, 1 stop bit,
1344 * no parity, no flow control lines, normal XON/XOFF chars */ 1344 * no parity, no flow control lines, normal XON/XOFF chars */
1345 1345
1346 if (rpn->param_mask & RFCOMM_RPN_PM_BITRATE) { 1346 if (rpn->param_mask & cpu_to_le16(RFCOMM_RPN_PM_BITRATE)) {
1347 bit_rate = rpn->bit_rate; 1347 bit_rate = rpn->bit_rate;
1348 if (bit_rate != RFCOMM_RPN_BR_115200) { 1348 if (bit_rate != RFCOMM_RPN_BR_115200) {
1349 BT_DBG("RPN bit rate mismatch 0x%x", bit_rate); 1349 BT_DBG("RPN bit rate mismatch 0x%x", bit_rate);
@@ -1352,7 +1352,7 @@ static int rfcomm_recv_rpn(struct rfcomm_session *s, int cr, int len, struct sk_
1352 } 1352 }
1353 } 1353 }
1354 1354
1355 if (rpn->param_mask & RFCOMM_RPN_PM_DATA) { 1355 if (rpn->param_mask & cpu_to_le16(RFCOMM_RPN_PM_DATA)) {
1356 data_bits = __get_rpn_data_bits(rpn->line_settings); 1356 data_bits = __get_rpn_data_bits(rpn->line_settings);
1357 if (data_bits != RFCOMM_RPN_DATA_8) { 1357 if (data_bits != RFCOMM_RPN_DATA_8) {
1358 BT_DBG("RPN data bits mismatch 0x%x", data_bits); 1358 BT_DBG("RPN data bits mismatch 0x%x", data_bits);
@@ -1361,7 +1361,7 @@ static int rfcomm_recv_rpn(struct rfcomm_session *s, int cr, int len, struct sk_
1361 } 1361 }
1362 } 1362 }
1363 1363
1364 if (rpn->param_mask & RFCOMM_RPN_PM_STOP) { 1364 if (rpn->param_mask & cpu_to_le16(RFCOMM_RPN_PM_STOP)) {
1365 stop_bits = __get_rpn_stop_bits(rpn->line_settings); 1365 stop_bits = __get_rpn_stop_bits(rpn->line_settings);
1366 if (stop_bits != RFCOMM_RPN_STOP_1) { 1366 if (stop_bits != RFCOMM_RPN_STOP_1) {
1367 BT_DBG("RPN stop bits mismatch 0x%x", stop_bits); 1367 BT_DBG("RPN stop bits mismatch 0x%x", stop_bits);
@@ -1370,7 +1370,7 @@ static int rfcomm_recv_rpn(struct rfcomm_session *s, int cr, int len, struct sk_
1370 } 1370 }
1371 } 1371 }
1372 1372
1373 if (rpn->param_mask & RFCOMM_RPN_PM_PARITY) { 1373 if (rpn->param_mask & cpu_to_le16(RFCOMM_RPN_PM_PARITY)) {
1374 parity = __get_rpn_parity(rpn->line_settings); 1374 parity = __get_rpn_parity(rpn->line_settings);
1375 if (parity != RFCOMM_RPN_PARITY_NONE) { 1375 if (parity != RFCOMM_RPN_PARITY_NONE) {
1376 BT_DBG("RPN parity mismatch 0x%x", parity); 1376 BT_DBG("RPN parity mismatch 0x%x", parity);
@@ -1379,7 +1379,7 @@ static int rfcomm_recv_rpn(struct rfcomm_session *s, int cr, int len, struct sk_
1379 } 1379 }
1380 } 1380 }
1381 1381
1382 if (rpn->param_mask & RFCOMM_RPN_PM_FLOW) { 1382 if (rpn->param_mask & cpu_to_le16(RFCOMM_RPN_PM_FLOW)) {
1383 flow_ctrl = rpn->flow_ctrl; 1383 flow_ctrl = rpn->flow_ctrl;
1384 if (flow_ctrl != RFCOMM_RPN_FLOW_NONE) { 1384 if (flow_ctrl != RFCOMM_RPN_FLOW_NONE) {
1385 BT_DBG("RPN flow ctrl mismatch 0x%x", flow_ctrl); 1385 BT_DBG("RPN flow ctrl mismatch 0x%x", flow_ctrl);
@@ -1388,7 +1388,7 @@ static int rfcomm_recv_rpn(struct rfcomm_session *s, int cr, int len, struct sk_
1388 } 1388 }
1389 } 1389 }
1390 1390
1391 if (rpn->param_mask & RFCOMM_RPN_PM_XON) { 1391 if (rpn->param_mask & cpu_to_le16(RFCOMM_RPN_PM_XON)) {
1392 xon_char = rpn->xon_char; 1392 xon_char = rpn->xon_char;
1393 if (xon_char != RFCOMM_RPN_XON_CHAR) { 1393 if (xon_char != RFCOMM_RPN_XON_CHAR) {
1394 BT_DBG("RPN XON char mismatch 0x%x", xon_char); 1394 BT_DBG("RPN XON char mismatch 0x%x", xon_char);
@@ -1397,7 +1397,7 @@ static int rfcomm_recv_rpn(struct rfcomm_session *s, int cr, int len, struct sk_
1397 } 1397 }
1398 } 1398 }
1399 1399
1400 if (rpn->param_mask & RFCOMM_RPN_PM_XOFF) { 1400 if (rpn->param_mask & cpu_to_le16(RFCOMM_RPN_PM_XOFF)) {
1401 xoff_char = rpn->xoff_char; 1401 xoff_char = rpn->xoff_char;
1402 if (xoff_char != RFCOMM_RPN_XOFF_CHAR) { 1402 if (xoff_char != RFCOMM_RPN_XOFF_CHAR) {
1403 BT_DBG("RPN XOFF char mismatch 0x%x", xoff_char); 1403 BT_DBG("RPN XOFF char mismatch 0x%x", xoff_char);