NFC: st21nfca: Fix host_list verification after SEactivation
authorChristophe Ricard <christophe.ricard@gmail.com>
Sun, 25 Oct 2015 21:54:42 +0000 (22:54 +0100)
committerSamuel Ortiz <sameo@linux.intel.com>
Tue, 27 Oct 2015 02:55:12 +0000 (03:55 +0100)
A secure element can be activated in different order.
The host_list is updated keeping a fixed order:
<terminal_host_id><uicc_id><ese_id>.

Cc: stable@vger.kernel.org
Signed-off-by: Christophe Ricard <christophe-h.ricard@st.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
drivers/nfc/st21nfca/se.c

index 6aa4e34c1d99254fdd674c93215de737a8535c3b..8e05d73b88ea83d64423c1e13f6f398fa856746c 100644 (file)
@@ -100,7 +100,7 @@ static int st21nfca_hci_control_se(struct nfc_hci_dev *hdev, u32 se_idx,
                                u8 state)
 {
        struct st21nfca_hci_info *info = nfc_hci_get_clientdata(hdev);
-       int r;
+       int r, i;
        struct sk_buff *sk_host_list;
        u8 se_event, host_id;
 
@@ -148,7 +148,10 @@ static int st21nfca_hci_control_se(struct nfc_hci_dev *hdev, u32 se_idx,
        if (r < 0)
                return r;
 
-       host_id = sk_host_list->data[sk_host_list->len - 1];
+       for (i = 0; i < sk_host_list->len &&
+               sk_host_list->data[i] != se_idx; i++)
+               ;
+       host_id = sk_host_list->data[i];
        kfree_skb(sk_host_list);
 
        if (state == ST21NFCA_SE_MODE_ON && host_id == se_idx)