NFC: llcp: Fix zero octets length SDU handling
LLCP Validation test #2 (Connection-less information transfer) send a service data unit of zero octets length. This is now handled correctly. Signed-off-by: Olivier Guiter <olivier.guiter@linux.intel.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
This commit is contained in:
parent
00e856db49
commit
0b23d666a8
1 changed files with 8 additions and 8 deletions
|
@ -694,8 +694,7 @@ int nfc_llcp_send_i_frame(struct nfc_llcp_sock *sock,
|
||||||
remaining_len = len;
|
remaining_len = len;
|
||||||
msg_ptr = msg_data;
|
msg_ptr = msg_data;
|
||||||
|
|
||||||
while (remaining_len > 0) {
|
do {
|
||||||
|
|
||||||
frag_len = min_t(size_t, sock->remote_miu, remaining_len);
|
frag_len = min_t(size_t, sock->remote_miu, remaining_len);
|
||||||
|
|
||||||
pr_debug("Fragment %zd bytes remaining %zd",
|
pr_debug("Fragment %zd bytes remaining %zd",
|
||||||
|
@ -708,6 +707,7 @@ int nfc_llcp_send_i_frame(struct nfc_llcp_sock *sock,
|
||||||
|
|
||||||
skb_put(pdu, LLCP_SEQUENCE_SIZE);
|
skb_put(pdu, LLCP_SEQUENCE_SIZE);
|
||||||
|
|
||||||
|
if (likely(frag_len > 0))
|
||||||
memcpy(skb_put(pdu, frag_len), msg_ptr, frag_len);
|
memcpy(skb_put(pdu, frag_len), msg_ptr, frag_len);
|
||||||
|
|
||||||
skb_queue_tail(&sock->tx_queue, pdu);
|
skb_queue_tail(&sock->tx_queue, pdu);
|
||||||
|
@ -720,7 +720,7 @@ int nfc_llcp_send_i_frame(struct nfc_llcp_sock *sock,
|
||||||
|
|
||||||
remaining_len -= frag_len;
|
remaining_len -= frag_len;
|
||||||
msg_ptr += frag_len;
|
msg_ptr += frag_len;
|
||||||
}
|
} while (remaining_len > 0);
|
||||||
|
|
||||||
kfree(msg_data);
|
kfree(msg_data);
|
||||||
|
|
||||||
|
@ -754,8 +754,7 @@ int nfc_llcp_send_ui_frame(struct nfc_llcp_sock *sock, u8 ssap, u8 dsap,
|
||||||
remaining_len = len;
|
remaining_len = len;
|
||||||
msg_ptr = msg_data;
|
msg_ptr = msg_data;
|
||||||
|
|
||||||
while (remaining_len > 0) {
|
do {
|
||||||
|
|
||||||
frag_len = min_t(size_t, sock->remote_miu, remaining_len);
|
frag_len = min_t(size_t, sock->remote_miu, remaining_len);
|
||||||
|
|
||||||
pr_debug("Fragment %zd bytes remaining %zd",
|
pr_debug("Fragment %zd bytes remaining %zd",
|
||||||
|
@ -770,6 +769,7 @@ int nfc_llcp_send_ui_frame(struct nfc_llcp_sock *sock, u8 ssap, u8 dsap,
|
||||||
|
|
||||||
pdu = llcp_add_header(pdu, dsap, ssap, LLCP_PDU_UI);
|
pdu = llcp_add_header(pdu, dsap, ssap, LLCP_PDU_UI);
|
||||||
|
|
||||||
|
if (likely(frag_len > 0))
|
||||||
memcpy(skb_put(pdu, frag_len), msg_ptr, frag_len);
|
memcpy(skb_put(pdu, frag_len), msg_ptr, frag_len);
|
||||||
|
|
||||||
/* No need to check for the peer RW for UI frames */
|
/* No need to check for the peer RW for UI frames */
|
||||||
|
@ -777,7 +777,7 @@ int nfc_llcp_send_ui_frame(struct nfc_llcp_sock *sock, u8 ssap, u8 dsap,
|
||||||
|
|
||||||
remaining_len -= frag_len;
|
remaining_len -= frag_len;
|
||||||
msg_ptr += frag_len;
|
msg_ptr += frag_len;
|
||||||
}
|
} while (remaining_len > 0);
|
||||||
|
|
||||||
kfree(msg_data);
|
kfree(msg_data);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue