diff options
author | Olivier Guiter <olivier.guiter@linux.intel.com> | 2013-03-25 06:24:21 -0400 |
---|---|---|
committer | Samuel Ortiz <sameo@linux.intel.com> | 2013-04-11 10:28:57 -0400 |
commit | 0b23d666a8857e521384d0eec75a7362b80a39b8 (patch) | |
tree | c60416548e56d5ba9ba6e63789cfdaf122da9ff1 /net/nfc | |
parent | 00e856db49bbaf0ec315bf81a3c4fc02e4d0beea (diff) |
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>
Diffstat (limited to 'net/nfc')
-rw-r--r-- | net/nfc/llcp/commands.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/net/nfc/llcp/commands.c b/net/nfc/llcp/commands.c index c5535cc9ed3a..199e8b5514f9 100644 --- a/net/nfc/llcp/commands.c +++ b/net/nfc/llcp/commands.c | |||
@@ -694,8 +694,7 @@ int nfc_llcp_send_i_frame(struct nfc_llcp_sock *sock, | |||
694 | remaining_len = len; | 694 | remaining_len = len; |
695 | msg_ptr = msg_data; | 695 | msg_ptr = msg_data; |
696 | 696 | ||
697 | while (remaining_len > 0) { | 697 | do { |
698 | |||
699 | frag_len = min_t(size_t, sock->remote_miu, remaining_len); | 698 | frag_len = min_t(size_t, sock->remote_miu, remaining_len); |
700 | 699 | ||
701 | pr_debug("Fragment %zd bytes remaining %zd", | 700 | pr_debug("Fragment %zd bytes remaining %zd", |
@@ -708,7 +707,8 @@ int nfc_llcp_send_i_frame(struct nfc_llcp_sock *sock, | |||
708 | 707 | ||
709 | skb_put(pdu, LLCP_SEQUENCE_SIZE); | 708 | skb_put(pdu, LLCP_SEQUENCE_SIZE); |
710 | 709 | ||
711 | memcpy(skb_put(pdu, frag_len), msg_ptr, frag_len); | 710 | if (likely(frag_len > 0)) |
711 | memcpy(skb_put(pdu, frag_len), msg_ptr, frag_len); | ||
712 | 712 | ||
713 | skb_queue_tail(&sock->tx_queue, pdu); | 713 | skb_queue_tail(&sock->tx_queue, pdu); |
714 | 714 | ||
@@ -720,7 +720,7 @@ int nfc_llcp_send_i_frame(struct nfc_llcp_sock *sock, | |||
720 | 720 | ||
721 | remaining_len -= frag_len; | 721 | remaining_len -= frag_len; |
722 | msg_ptr += frag_len; | 722 | msg_ptr += frag_len; |
723 | } | 723 | } while (remaining_len > 0); |
724 | 724 | ||
725 | kfree(msg_data); | 725 | kfree(msg_data); |
726 | 726 | ||
@@ -754,8 +754,7 @@ int nfc_llcp_send_ui_frame(struct nfc_llcp_sock *sock, u8 ssap, u8 dsap, | |||
754 | remaining_len = len; | 754 | remaining_len = len; |
755 | msg_ptr = msg_data; | 755 | msg_ptr = msg_data; |
756 | 756 | ||
757 | while (remaining_len > 0) { | 757 | do { |
758 | |||
759 | frag_len = min_t(size_t, sock->remote_miu, remaining_len); | 758 | frag_len = min_t(size_t, sock->remote_miu, remaining_len); |
760 | 759 | ||
761 | pr_debug("Fragment %zd bytes remaining %zd", | 760 | pr_debug("Fragment %zd bytes remaining %zd", |
@@ -770,14 +769,15 @@ int nfc_llcp_send_ui_frame(struct nfc_llcp_sock *sock, u8 ssap, u8 dsap, | |||
770 | 769 | ||
771 | pdu = llcp_add_header(pdu, dsap, ssap, LLCP_PDU_UI); | 770 | pdu = llcp_add_header(pdu, dsap, ssap, LLCP_PDU_UI); |
772 | 771 | ||
773 | memcpy(skb_put(pdu, frag_len), msg_ptr, frag_len); | 772 | if (likely(frag_len > 0)) |
773 | memcpy(skb_put(pdu, frag_len), msg_ptr, frag_len); | ||
774 | 774 | ||
775 | /* No need to check for the peer RW for UI frames */ | 775 | /* No need to check for the peer RW for UI frames */ |
776 | skb_queue_tail(&local->tx_queue, pdu); | 776 | skb_queue_tail(&local->tx_queue, pdu); |
777 | 777 | ||
778 | remaining_len -= frag_len; | 778 | remaining_len -= frag_len; |
779 | msg_ptr += frag_len; | 779 | msg_ptr += frag_len; |
780 | } | 780 | } while (remaining_len > 0); |
781 | 781 | ||
782 | kfree(msg_data); | 782 | kfree(msg_data); |
783 | 783 | ||