remaining_len = len;
msg_ptr = msg_data;
- while (remaining_len > 0) {
-
+ do {
frag_len = min_t(size_t, sock->remote_miu, remaining_len);
pr_debug("Fragment %zd bytes remaining %zd",
skb_put(pdu, LLCP_SEQUENCE_SIZE);
- memcpy(skb_put(pdu, frag_len), msg_ptr, frag_len);
+ if (likely(frag_len > 0))
+ memcpy(skb_put(pdu, frag_len), msg_ptr, frag_len);
skb_queue_tail(&sock->tx_queue, pdu);
remaining_len -= frag_len;
msg_ptr += frag_len;
- }
+ } while (remaining_len > 0);
kfree(msg_data);
remaining_len = len;
msg_ptr = msg_data;
- while (remaining_len > 0) {
-
+ do {
frag_len = min_t(size_t, sock->remote_miu, remaining_len);
pr_debug("Fragment %zd bytes remaining %zd",
pdu = llcp_add_header(pdu, dsap, ssap, LLCP_PDU_UI);
- memcpy(skb_put(pdu, frag_len), msg_ptr, frag_len);
+ if (likely(frag_len > 0))
+ memcpy(skb_put(pdu, frag_len), msg_ptr, frag_len);
/* No need to check for the peer RW for UI frames */
skb_queue_tail(&local->tx_queue, pdu);
remaining_len -= frag_len;
msg_ptr += frag_len;
- }
+ } while (remaining_len > 0);
kfree(msg_data);