Commit f11d676d authored by Gustavo F. Padovan's avatar Gustavo F. Padovan Committed by Marcel Holtmann

Bluetooth: Refactor l2cap_retransmit_frame()

Make the code flow cleaner and changes the function to void.
It also fixes a potential NULL dereference with skb.
Signed-off-by: default avatarGustavo F. Padovan <padovan@profusion.mobi>
Reviewed-by: default avatarJoão Paulo Rechi Vita <jprvita@profusion.mobi>
Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
parent 9a9c6a34
...@@ -1331,25 +1331,29 @@ static int l2cap_streaming_send(struct sock *sk) ...@@ -1331,25 +1331,29 @@ static int l2cap_streaming_send(struct sock *sk)
return 0; return 0;
} }
static int l2cap_retransmit_frame(struct sock *sk, u8 tx_seq) static void l2cap_retransmit_frame(struct sock *sk, u8 tx_seq)
{ {
struct l2cap_pinfo *pi = l2cap_pi(sk); struct l2cap_pinfo *pi = l2cap_pi(sk);
struct sk_buff *skb, *tx_skb; struct sk_buff *skb, *tx_skb;
u16 control, fcs; u16 control, fcs;
skb = skb_peek(TX_QUEUE(sk)); skb = skb_peek(TX_QUEUE(sk));
if (!skb)
return;
do { do {
if (bt_cb(skb)->tx_seq != tx_seq) { if (bt_cb(skb)->tx_seq == tx_seq)
if (skb_queue_is_last(TX_QUEUE(sk), skb))
break; break;
skb = skb_queue_next(TX_QUEUE(sk), skb);
continue; if (skb_queue_is_last(TX_QUEUE(sk), skb))
} return;
} while ((skb = skb_queue_next(TX_QUEUE(sk), skb)));
if (pi->remote_max_tx && if (pi->remote_max_tx &&
bt_cb(skb)->retries == pi->remote_max_tx) { bt_cb(skb)->retries == pi->remote_max_tx) {
l2cap_send_disconn_req(pi->conn, sk); l2cap_send_disconn_req(pi->conn, sk);
break; return;
} }
tx_skb = skb_clone(skb, GFP_ATOMIC); tx_skb = skb_clone(skb, GFP_ATOMIC);
...@@ -1365,9 +1369,6 @@ static int l2cap_retransmit_frame(struct sock *sk, u8 tx_seq) ...@@ -1365,9 +1369,6 @@ static int l2cap_retransmit_frame(struct sock *sk, u8 tx_seq)
} }
l2cap_do_send(sk, tx_skb); l2cap_do_send(sk, tx_skb);
break;
} while(1);
return 0;
} }
static int l2cap_ertm_send(struct sock *sk) static int l2cap_ertm_send(struct sock *sk)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment