From: Christophe Ricard Date: Mon, 31 Mar 2014 22:34:02 +0000 (+0200) Subject: NFC: st21nfca: Fix warning: array subscript is above array bounds X-Git-Tag: next-20140530~73^2~60^2~20 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=e8efab6e6bad1bb116bb9dfa6e0f65dd1bb9cc0e;p=karo-tx-linux.git NFC: st21nfca: Fix warning: array subscript is above array bounds Fix "warning: array subscript is above array bounds" in load_session Signed-off-by: Christophe Ricard Signed-off-by: Samuel Ortiz --- diff --git a/drivers/nfc/st21nfca/st21nfca.c b/drivers/nfc/st21nfca/st21nfca.c index 32d5e8742ee8..d9fe09ea26a5 100644 --- a/drivers/nfc/st21nfca/st21nfca.c +++ b/drivers/nfc/st21nfca/st21nfca.c @@ -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] =