Commit e073eb67 authored by Thierry Escande's avatar Thierry Escande Committed by Samuel Ortiz

NFC: digital: Rework ACK PDU handling in initiator mode

With this patch, ACK PDU sk_buffs are now freed and code has been
refactored for better errors handling.
Signed-off-by: default avatarThierry Escande <thierry.escande@collabora.com>
Signed-off-by: default avatarSamuel Ortiz <sameo@linux.intel.com>
parent 482333b2
...@@ -782,6 +782,12 @@ static void digital_in_recv_dep_res(struct nfc_digital_dev *ddev, void *arg, ...@@ -782,6 +782,12 @@ static void digital_in_recv_dep_res(struct nfc_digital_dev *ddev, void *arg,
break; break;
case DIGITAL_NFC_DEP_PFB_ACK_NACK_PDU: case DIGITAL_NFC_DEP_PFB_ACK_NACK_PDU:
if (DIGITAL_NFC_DEP_NACK_BIT_SET(pfb)) {
PROTOCOL_ERR("14.12.4.5");
rc = -EIO;
goto exit;
}
if (DIGITAL_NFC_DEP_PFB_PNI(pfb) != ddev->curr_nfc_dep_pni) { if (DIGITAL_NFC_DEP_PFB_PNI(pfb) != ddev->curr_nfc_dep_pni) {
PROTOCOL_ERR("14.12.3.3"); PROTOCOL_ERR("14.12.3.3");
rc = -EIO; rc = -EIO;
...@@ -791,7 +797,15 @@ static void digital_in_recv_dep_res(struct nfc_digital_dev *ddev, void *arg, ...@@ -791,7 +797,15 @@ static void digital_in_recv_dep_res(struct nfc_digital_dev *ddev, void *arg,
ddev->curr_nfc_dep_pni = ddev->curr_nfc_dep_pni =
DIGITAL_NFC_DEP_PFB_PNI(ddev->curr_nfc_dep_pni + 1); DIGITAL_NFC_DEP_PFB_PNI(ddev->curr_nfc_dep_pni + 1);
if (ddev->chaining_skb && !DIGITAL_NFC_DEP_NACK_BIT_SET(pfb)) { if (!ddev->chaining_skb) {
PROTOCOL_ERR("14.12.4.3");
rc = -EIO;
goto exit;
}
/* The initiator has received a valid ACK. Free the last sent
* PDU and keep on sending chained skb.
*/
kfree_skb(ddev->saved_skb); kfree_skb(ddev->saved_skb);
ddev->saved_skb = NULL; ddev->saved_skb = NULL;
...@@ -801,12 +815,7 @@ static void digital_in_recv_dep_res(struct nfc_digital_dev *ddev, void *arg, ...@@ -801,12 +815,7 @@ static void digital_in_recv_dep_res(struct nfc_digital_dev *ddev, void *arg,
if (rc) if (rc)
goto error; goto error;
return; goto free_resp;
}
pr_err("Received a ACK/NACK PDU\n");
rc = -EINVAL;
goto exit;
case DIGITAL_NFC_DEP_PFB_SUPERVISOR_PDU: case DIGITAL_NFC_DEP_PFB_SUPERVISOR_PDU:
if (!DIGITAL_NFC_DEP_PFB_IS_TIMEOUT(pfb)) { /* ATN */ if (!DIGITAL_NFC_DEP_PFB_IS_TIMEOUT(pfb)) { /* ATN */
...@@ -839,6 +848,11 @@ static void digital_in_recv_dep_res(struct nfc_digital_dev *ddev, void *arg, ...@@ -839,6 +848,11 @@ static void digital_in_recv_dep_res(struct nfc_digital_dev *ddev, void *arg,
if (rc) if (rc)
kfree_skb(resp); kfree_skb(resp);
return;
free_resp:
dev_kfree_skb(resp);
} }
int digital_in_send_dep_req(struct nfc_digital_dev *ddev, int digital_in_send_dep_req(struct nfc_digital_dev *ddev,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment