|
@@ -131,7 +131,8 @@ static int bnep_ctrl_set_netfilter(struct bnep_session *s, __be16 *data, int len
|
|
return -EILSEQ;
|
|
return -EILSEQ;
|
|
|
|
|
|
n = get_unaligned_be16(data);
|
|
n = get_unaligned_be16(data);
|
|
- data++; len -= 2;
|
|
|
|
|
|
+ data++;
|
|
|
|
+ len -= 2;
|
|
|
|
|
|
if (len < n)
|
|
if (len < n)
|
|
return -EILSEQ;
|
|
return -EILSEQ;
|
|
@@ -176,7 +177,8 @@ static int bnep_ctrl_set_mcfilter(struct bnep_session *s, u8 *data, int len)
|
|
return -EILSEQ;
|
|
return -EILSEQ;
|
|
|
|
|
|
n = get_unaligned_be16(data);
|
|
n = get_unaligned_be16(data);
|
|
- data += 2; len -= 2;
|
|
|
|
|
|
+ data += 2;
|
|
|
|
+ len -= 2;
|
|
|
|
|
|
if (len < n)
|
|
if (len < n)
|
|
return -EILSEQ;
|
|
return -EILSEQ;
|
|
@@ -198,8 +200,10 @@ static int bnep_ctrl_set_mcfilter(struct bnep_session *s, u8 *data, int len)
|
|
for (; n > 0; n--) {
|
|
for (; n > 0; n--) {
|
|
u8 a1[6], *a2;
|
|
u8 a1[6], *a2;
|
|
|
|
|
|
- memcpy(a1, data, ETH_ALEN); data += ETH_ALEN;
|
|
|
|
- a2 = data; data += ETH_ALEN;
|
|
|
|
|
|
+ memcpy(a1, data, ETH_ALEN);
|
|
|
|
+ data += ETH_ALEN;
|
|
|
|
+ a2 = data;
|
|
|
|
+ data += ETH_ALEN;
|
|
|
|
|
|
BT_DBG("mc filter %s -> %s",
|
|
BT_DBG("mc filter %s -> %s",
|
|
batostr((void *) a1), batostr((void *) a2));
|
|
batostr((void *) a1), batostr((void *) a2));
|
|
@@ -231,7 +235,8 @@ static int bnep_rx_control(struct bnep_session *s, void *data, int len)
|
|
u8 cmd = *(u8 *)data;
|
|
u8 cmd = *(u8 *)data;
|
|
int err = 0;
|
|
int err = 0;
|
|
|
|
|
|
- data++; len--;
|
|
|
|
|
|
+ data++;
|
|
|
|
+ len--;
|
|
|
|
|
|
switch (cmd) {
|
|
switch (cmd) {
|
|
case BNEP_CMD_NOT_UNDERSTOOD:
|
|
case BNEP_CMD_NOT_UNDERSTOOD:
|
|
@@ -315,7 +320,8 @@ static inline int bnep_rx_frame(struct bnep_session *s, struct sk_buff *skb)
|
|
|
|
|
|
dev->stats.rx_bytes += skb->len;
|
|
dev->stats.rx_bytes += skb->len;
|
|
|
|
|
|
- type = *(u8 *) skb->data; skb_pull(skb, 1);
|
|
|
|
|
|
+ type = *(u8 *) skb->data;
|
|
|
|
+ skb_pull(skb, 1);
|
|
|
|
|
|
if ((type & BNEP_TYPE_MASK) >= sizeof(__bnep_rx_hlen))
|
|
if ((type & BNEP_TYPE_MASK) >= sizeof(__bnep_rx_hlen))
|
|
goto badframe;
|
|
goto badframe;
|
|
@@ -370,14 +376,14 @@ static inline int bnep_rx_frame(struct bnep_session *s, struct sk_buff *skb)
|
|
|
|
|
|
case BNEP_COMPRESSED_DST_ONLY:
|
|
case BNEP_COMPRESSED_DST_ONLY:
|
|
memcpy(__skb_put(nskb, ETH_ALEN), skb_mac_header(skb),
|
|
memcpy(__skb_put(nskb, ETH_ALEN), skb_mac_header(skb),
|
|
- ETH_ALEN);
|
|
|
|
|
|
+ ETH_ALEN);
|
|
memcpy(__skb_put(nskb, ETH_ALEN + 2), s->eh.h_source,
|
|
memcpy(__skb_put(nskb, ETH_ALEN + 2), s->eh.h_source,
|
|
- ETH_ALEN + 2);
|
|
|
|
|
|
+ ETH_ALEN + 2);
|
|
break;
|
|
break;
|
|
|
|
|
|
case BNEP_GENERAL:
|
|
case BNEP_GENERAL:
|
|
memcpy(__skb_put(nskb, ETH_ALEN * 2), skb_mac_header(skb),
|
|
memcpy(__skb_put(nskb, ETH_ALEN * 2), skb_mac_header(skb),
|
|
- ETH_ALEN * 2);
|
|
|
|
|
|
+ ETH_ALEN * 2);
|
|
put_unaligned(s->eh.h_proto, (__be16 *) __skb_put(nskb, 2));
|
|
put_unaligned(s->eh.h_proto, (__be16 *) __skb_put(nskb, 2));
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
@@ -481,7 +487,7 @@ static int bnep_session(void *arg)
|
|
while (!atomic_read(&s->killed)) {
|
|
while (!atomic_read(&s->killed)) {
|
|
set_current_state(TASK_INTERRUPTIBLE);
|
|
set_current_state(TASK_INTERRUPTIBLE);
|
|
|
|
|
|
- // RX
|
|
|
|
|
|
+ /* RX */
|
|
while ((skb = skb_dequeue(&sk->sk_receive_queue))) {
|
|
while ((skb = skb_dequeue(&sk->sk_receive_queue))) {
|
|
skb_orphan(skb);
|
|
skb_orphan(skb);
|
|
bnep_rx_frame(s, skb);
|
|
bnep_rx_frame(s, skb);
|
|
@@ -490,7 +496,7 @@ static int bnep_session(void *arg)
|
|
if (sk->sk_state != BT_CONNECTED)
|
|
if (sk->sk_state != BT_CONNECTED)
|
|
break;
|
|
break;
|
|
|
|
|
|
- // TX
|
|
|
|
|
|
+ /* TX */
|
|
while ((skb = skb_dequeue(&sk->sk_write_queue)))
|
|
while ((skb = skb_dequeue(&sk->sk_write_queue)))
|
|
if (bnep_tx_frame(s, skb))
|
|
if (bnep_tx_frame(s, skb))
|
|
break;
|
|
break;
|
|
@@ -558,8 +564,8 @@ int bnep_add_connection(struct bnep_connadd_req *req, struct socket *sock)
|
|
|
|
|
|
/* session struct allocated as private part of net_device */
|
|
/* session struct allocated as private part of net_device */
|
|
dev = alloc_netdev(sizeof(struct bnep_session),
|
|
dev = alloc_netdev(sizeof(struct bnep_session),
|
|
- (*req->device) ? req->device : "bnep%d",
|
|
|
|
- bnep_net_setup);
|
|
|
|
|
|
+ (*req->device) ? req->device : "bnep%d",
|
|
|
|
+ bnep_net_setup);
|
|
if (!dev)
|
|
if (!dev)
|
|
return -ENOMEM;
|
|
return -ENOMEM;
|
|
|
|
|
|
@@ -574,7 +580,7 @@ int bnep_add_connection(struct bnep_connadd_req *req, struct socket *sock)
|
|
s = netdev_priv(dev);
|
|
s = netdev_priv(dev);
|
|
|
|
|
|
/* This is rx header therefore addresses are swapped.
|
|
/* This is rx header therefore addresses are swapped.
|
|
- * ie eh.h_dest is our local address. */
|
|
|
|
|
|
+ * ie. eh.h_dest is our local address. */
|
|
memcpy(s->eh.h_dest, &src, ETH_ALEN);
|
|
memcpy(s->eh.h_dest, &src, ETH_ALEN);
|
|
memcpy(s->eh.h_source, &dst, ETH_ALEN);
|
|
memcpy(s->eh.h_source, &dst, ETH_ALEN);
|
|
memcpy(dev->dev_addr, s->eh.h_dest, ETH_ALEN);
|
|
memcpy(dev->dev_addr, s->eh.h_dest, ETH_ALEN);
|
|
@@ -600,9 +606,8 @@ int bnep_add_connection(struct bnep_connadd_req *req, struct socket *sock)
|
|
SET_NETDEV_DEVTYPE(dev, &bnep_type);
|
|
SET_NETDEV_DEVTYPE(dev, &bnep_type);
|
|
|
|
|
|
err = register_netdev(dev);
|
|
err = register_netdev(dev);
|
|
- if (err) {
|
|
|
|
|
|
+ if (err)
|
|
goto failed;
|
|
goto failed;
|
|
- }
|
|
|
|
|
|
|
|
__bnep_link_session(s);
|
|
__bnep_link_session(s);
|
|
|
|
|