Skip to contentSkip to conversation

NFC: Fragment LLCP I frames

DISCUSSION Dan Carpenter 2 participants 3 messages Mar 7, 2012 – Mar 8, 2012

lore
Share & tools
lore
#0 lore raw

Hi Samuel,

I had some questions about the patch e65b0f46edfd: "NFC: Fragment LLCP I frames" from Mar 5, 2012.

net/nfc/llcp/commands.c
+ while (remaining_len > 0) {
+

+               frag_len = min_t(u16, local->remote_miu, remaining_len);
                                 ^^^

This should be a cast to size_t. Otherwise for a large value of remaining_len we'd loop until we hit an allocation failure with pdu = llcp_allocate_pdu();

- sk = &sock->sk;
- lock_sock(sk);
+ pr_debug("Fragment %zd bytes remaining %zd",
+ frag_len, remaining_len);

- nfc_llcp_queue_i_frames(sock);
+ pdu = llcp_allocate_pdu(sock, LLCP_PDU_I,
+ frag_len + LLCP_SEQUENCE_SIZE);
+ if (pdu == NULL)
+ return -ENOMEM;
+
+ skb_put(pdu, LLCP_SEQUENCE_SIZE);
+
+ memcpy(skb_put(pdu, frag_len), msg_ptr, frag_len);
+
+ skb_queue_head(&sock->tx_queue, pdu);
+
+ lock_sock(sk);
+
+ nfc_llcp_queue_i_frames(sock);
+
+ release_sock(sk);
+
+ remaining_len -= frag_len;
+ msg_ptr += len;

Shouldn't this be msg_ptr += frag_len?

+ }

regards,
dan carpenter

#1 lore raw

Hi Dan,

Quoted 11 lines · Dan Carpenter

Hi Samuel,

I had some questions about the patch e65b0f46edfd: "NFC: Fragment LLCP I frames" from Mar 5, 2012.

net/nfc/llcp/commands.c

(quoted diff) +3 -0
+       while (remaining_len > 0) {
+
+               frag_len = min_t(u16, local->remote_miu, remaining_len);
                                 ^^^
Quoted 3 lines

This should be a cast to size_t. Otherwise for a large value of remaining_len we'd loop until we hit an allocation failure with pdu = llcp_allocate_pdu();

Right.

Quoted 20 lines
(quoted diff) +19 -0
+               pdu = llcp_allocate_pdu(sock, LLCP_PDU_I,
+                                       frag_len + LLCP_SEQUENCE_SIZE);
+               if (pdu == NULL)
+                       return -ENOMEM;
+
+               skb_put(pdu, LLCP_SEQUENCE_SIZE);
+
+               memcpy(skb_put(pdu, frag_len), msg_ptr, frag_len);
+
+               skb_queue_head(&sock->tx_queue, pdu);
+
+               lock_sock(sk);
+
+               nfc_llcp_queue_i_frames(sock);
+
+               release_sock(sk);
+
+               remaining_len -= frag_len;
+               msg_ptr += len;
Quoted 1 line

Shouldn't this be msg_ptr += frag_len?

Right as well.
I'll send an patch to John for fixing that. Do you mind me adding a:

to it ?

Cheers,
Samuel.

Signature · 2 lines
Intel Open Source Technology Centre
http://oss.intel.com/
#2 lore raw
Quoted 6 lines · Samuel Ortiz
Quoted 1 line

Shouldn't this be msg_ptr += frag_len?

Right as well.
I'll send an patch to John for fixing that. Do you mind me adding a:

to it ?

That would be great.

regards,
dan carpenter