Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f11d676d authored by Gustavo Padovan's avatar Gustavo Padovan Committed by Marcel Holtmann
Browse files

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
Loading
Loading
Loading
Loading
+27 −26
Original line number Diff line number Diff line
@@ -1331,25 +1331,29 @@ static int l2cap_streaming_send(struct sock *sk)
	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 sk_buff *skb, *tx_skb;
	u16 control, fcs;

	skb = skb_peek(TX_QUEUE(sk));
	if (!skb)
		return;

	do {
		if (bt_cb(skb)->tx_seq != tx_seq) {
			if (skb_queue_is_last(TX_QUEUE(sk), skb))
		if (bt_cb(skb)->tx_seq == tx_seq)
			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 &&
			bt_cb(skb)->retries == pi->remote_max_tx) {
		l2cap_send_disconn_req(pi->conn, sk);
			break;
		return;
	}

	tx_skb = skb_clone(skb, GFP_ATOMIC);
@@ -1365,9 +1369,6 @@ static int l2cap_retransmit_frame(struct sock *sk, u8 tx_seq)
	}

	l2cap_do_send(sk, tx_skb);
		break;
	} while(1);
	return 0;
}

static int l2cap_ertm_send(struct sock *sk)