NFC: st21nfca: Fix incorrect byte stuffing revocation
authorChristophe Ricard <christophe.ricard@gmail.com>
Thu, 24 Apr 2014 21:19:32 +0000 (23:19 +0200)
committerSamuel Ortiz <sameo@linux.intel.com>
Sun, 4 May 2014 22:06:27 +0000 (00:06 +0200)
Byte stuffing was not correctly removed after a i2c read operation.
This was causing improper crc calculation when byte stuffing was
applied to more than 1 byte.

Signed-off-by: Christophe Ricard <christophe-h.ricard@st.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
drivers/nfc/st21nfca/i2c.c

index 6c4d0a0fc7fca72a968da7a544f8451afd9875ab..4df15ef2528a05fa20761565fcfe8379d8a55cce 100644 (file)
@@ -315,11 +315,10 @@ static int st21nfca_hci_i2c_repack(struct sk_buff *skb)
                skb_trim(skb, size);
                /* remove ST21NFCA byte stuffing for upper layer */
                for (i = 1, j = 0; i < skb->len; i++) {
-                       if (skb->data[i] ==
+                       if (skb->data[i + j] ==
                                        (u8) ST21NFCA_ESCAPE_BYTE_STUFFING) {
-                               skb->data[i] =
-                                   skb->data[i +
-                                             1] | ST21NFCA_BYTE_STUFFING_MASK;
+                               skb->data[i] = skb->data[i + j + 1]
+                                               | ST21NFCA_BYTE_STUFFING_MASK;
                                i++;
                                j++;
                        }