NFC: st21nfca: Fix warning: array subscript is above array bounds
authorChristophe Ricard <christophe.ricard@gmail.com>
Mon, 31 Mar 2014 22:34:02 +0000 (00:34 +0200)
committerSamuel Ortiz <sameo@linux.intel.com>
Mon, 21 Apr 2014 22:37:29 +0000 (00:37 +0200)
Fix "warning: array subscript is above array bounds" in load_session

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

index 32d5e8742ee8d8d6fa8040be3b109c1721ed42f5..d9fe09ea26a519ecf370bdc78ad461ab04216fd4 100644 (file)
@@ -167,14 +167,14 @@ static int st21nfca_hci_load_session(struct nfc_hci_dev *hdev)
                 * - destination hid (1byte)
                 * - destination gid (1byte)
                 */
-               info = (struct st21nfca_pipe_info *)
-                                       skb_pipe_info->data;
+               info = (struct st21nfca_pipe_info *) skb_pipe_info->data;
                for (j = 0; (j < ARRAY_SIZE(st21nfca_gates)) &&
                        (st21nfca_gates[j].gate != info->dst_gate_id);
                        j++)
                        ;
 
-               if (st21nfca_gates[j].gate == info->dst_gate_id &&
+               if (j < ARRAY_SIZE(st21nfca_gates) &&
+                       st21nfca_gates[j].gate == info->dst_gate_id &&
                        ST21NFCA_DM_IS_PIPE_OPEN(info->pipe_state)) {
                        st21nfca_gates[j].pipe = pipe_info[2];
                        hdev->gate2pipe[st21nfca_gates[j].gate] =