Commit fa885c63 authored by Christophe Ricard's avatar Christophe Ricard Committed by Greg Kroah-Hartman

NFC: nci: Fix incorrect data chaining when sending data

commit 500c4ef0 upstream.

When sending HCI data over NCI, cmd information should be
present only on the first packet.
Each packet shall be specifically allocated and sent to the
NCI layer.
Signed-off-by: default avatarChristophe Ricard <christophe-h.ricard@st.com>
Signed-off-by: default avatarSamuel Ortiz <sameo@linux.intel.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 306105dc
...@@ -146,18 +146,18 @@ static int nci_hci_send_data(struct nci_dev *ndev, u8 pipe, ...@@ -146,18 +146,18 @@ static int nci_hci_send_data(struct nci_dev *ndev, u8 pipe,
if (!conn_info) if (!conn_info)
return -EPROTO; return -EPROTO;
skb = nci_skb_alloc(ndev, 2 + conn_info->max_pkt_payload_len + i = 0;
skb = nci_skb_alloc(ndev, conn_info->max_pkt_payload_len +
NCI_DATA_HDR_SIZE, GFP_KERNEL); NCI_DATA_HDR_SIZE, GFP_KERNEL);
if (!skb) if (!skb)
return -ENOMEM; return -ENOMEM;
skb_reserve(skb, 2 + NCI_DATA_HDR_SIZE); skb_reserve(skb, NCI_DATA_HDR_SIZE + 2);
*skb_push(skb, 1) = data_type; *skb_push(skb, 1) = data_type;
i = 0;
len = conn_info->max_pkt_payload_len;
do { do {
len = conn_info->max_pkt_payload_len;
/* If last packet add NCI_HFP_NO_CHAINING */ /* If last packet add NCI_HFP_NO_CHAINING */
if (i + conn_info->max_pkt_payload_len - if (i + conn_info->max_pkt_payload_len -
(skb->len + 1) >= data_len) { (skb->len + 1) >= data_len) {
...@@ -177,9 +177,15 @@ static int nci_hci_send_data(struct nci_dev *ndev, u8 pipe, ...@@ -177,9 +177,15 @@ static int nci_hci_send_data(struct nci_dev *ndev, u8 pipe,
return r; return r;
i += len; i += len;
if (i < data_len) { if (i < data_len) {
skb_trim(skb, 0); skb = nci_skb_alloc(ndev,
skb_pull(skb, len); conn_info->max_pkt_payload_len +
NCI_DATA_HDR_SIZE, GFP_KERNEL);
if (!skb)
return -ENOMEM;
skb_reserve(skb, NCI_DATA_HDR_SIZE + 1);
} }
} while (i < data_len); } while (i < data_len);
......
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