aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristophe Ricard <christophe.ricard@gmail.com>2015-01-25 17:33:28 -0500
committerSamuel Ortiz <sameo@linux.intel.com>2015-01-26 17:14:34 -0500
commitc490c557b67fddfc7d733455d86500080ba717b6 (patch)
tree4e8821de45751b6c9491cec960f06ac71ea84d63
parent2b702832ded5c0af4bc333396ad9527eabe72020 (diff)
NFC: st21nfca: Fix some skb memory leaks
Fix some memory leaks after some nfc_hci_get_param calls. Signed-off-by: Christophe Ricard <christophe-h.ricard@st.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
-rw-r--r--drivers/nfc/st21nfca/st21nfca.c37
1 files changed, 21 insertions, 16 deletions
diff --git a/drivers/nfc/st21nfca/st21nfca.c b/drivers/nfc/st21nfca/st21nfca.c
index 0667272cca98..7cb7ce47d2af 100644
--- a/drivers/nfc/st21nfca/st21nfca.c
+++ b/drivers/nfc/st21nfca/st21nfca.c
@@ -261,8 +261,9 @@ static int st21nfca_hci_ready(struct nfc_hci_dev *hdev)
261 if (r < 0) 261 if (r < 0)
262 return r; 262 return r;
263 263
264 if (skb->data[0] == 0) { 264 param = skb->data[0];
265 kfree_skb(skb); 265 kfree_skb(skb);
266 if (param == 0) {
266 param = 1; 267 param = 1;
267 268
268 r = nfc_hci_set_param(hdev, ST21NFCA_DEVICE_MGNT_GATE, 269 r = nfc_hci_set_param(hdev, ST21NFCA_DEVICE_MGNT_GATE,
@@ -404,9 +405,12 @@ static int st21nfca_hci_start_poll(struct nfc_hci_dev *hdev,
404 r = nfc_hci_set_param(hdev, ST21NFCA_RF_CARD_F_GATE, 405 r = nfc_hci_set_param(hdev, ST21NFCA_RF_CARD_F_GATE,
405 ST21NFCA_RF_CARD_F_DATARATE, 406 ST21NFCA_RF_CARD_F_DATARATE,
406 param, 1); 407 param, 1);
407 if (r < 0) 408 if (r < 0) {
409 kfree_skb(datarate_skb);
408 return r; 410 return r;
411 }
409 } 412 }
413 kfree_skb(datarate_skb);
410 414
411 /* 415 /*
412 * Configure sens_res 416 * Configure sens_res
@@ -660,15 +664,15 @@ static int st21nfca_hci_complete_target_discovered(struct nfc_hci_dev *hdev,
660 struct nfc_target *target) 664 struct nfc_target *target)
661{ 665{
662 int r; 666 int r;
663 struct sk_buff *nfcid2_skb = NULL, *nfcid1_skb; 667 struct sk_buff *nfcid_skb = NULL;
664 668
665 if (gate == ST21NFCA_RF_READER_F_GATE) { 669 if (gate == ST21NFCA_RF_READER_F_GATE) {
666 r = nfc_hci_get_param(hdev, ST21NFCA_RF_READER_F_GATE, 670 r = nfc_hci_get_param(hdev, ST21NFCA_RF_READER_F_GATE,
667 ST21NFCA_RF_READER_F_NFCID2, &nfcid2_skb); 671 ST21NFCA_RF_READER_F_NFCID2, &nfcid_skb);
668 if (r < 0) 672 if (r < 0)
669 goto exit; 673 goto exit;
670 674
671 if (nfcid2_skb->len > NFC_SENSF_RES_MAXSIZE) { 675 if (nfcid_skb->len > NFC_SENSF_RES_MAXSIZE) {
672 r = -EPROTO; 676 r = -EPROTO;
673 goto exit; 677 goto exit;
674 } 678 }
@@ -680,11 +684,11 @@ static int st21nfca_hci_complete_target_discovered(struct nfc_hci_dev *hdev,
680 * - After the reception of SEL_RES with NFCIP-1 compliant bit 684 * - After the reception of SEL_RES with NFCIP-1 compliant bit
681 * set for type A frame NFCID1 will be updated 685 * set for type A frame NFCID1 will be updated
682 */ 686 */
683 if (nfcid2_skb->len > 0) { 687 if (nfcid_skb->len > 0) {
684 /* P2P in type F */ 688 /* P2P in type F */
685 memcpy(target->sensf_res, nfcid2_skb->data, 689 memcpy(target->sensf_res, nfcid_skb->data,
686 nfcid2_skb->len); 690 nfcid_skb->len);
687 target->sensf_res_len = nfcid2_skb->len; 691 target->sensf_res_len = nfcid_skb->len;
688 /* NFC Forum Digital Protocol Table 44 */ 692 /* NFC Forum Digital Protocol Table 44 */
689 if (target->sensf_res[0] == 0x01 && 693 if (target->sensf_res[0] == 0x01 &&
690 target->sensf_res[1] == 0xfe) 694 target->sensf_res[1] == 0xfe)
@@ -694,27 +698,28 @@ static int st21nfca_hci_complete_target_discovered(struct nfc_hci_dev *hdev,
694 target->supported_protocols = 698 target->supported_protocols =
695 NFC_PROTO_FELICA_MASK; 699 NFC_PROTO_FELICA_MASK;
696 } else { 700 } else {
701 kfree_skb(nfcid_skb);
697 /* P2P in type A */ 702 /* P2P in type A */
698 r = nfc_hci_get_param(hdev, ST21NFCA_RF_READER_F_GATE, 703 r = nfc_hci_get_param(hdev, ST21NFCA_RF_READER_F_GATE,
699 ST21NFCA_RF_READER_F_NFCID1, 704 ST21NFCA_RF_READER_F_NFCID1,
700 &nfcid1_skb); 705 &nfcid_skb);
701 if (r < 0) 706 if (r < 0)
702 goto exit; 707 goto exit;
703 708
704 if (nfcid1_skb->len > NFC_NFCID1_MAXSIZE) { 709 if (nfcid_skb->len > NFC_NFCID1_MAXSIZE) {
705 r = -EPROTO; 710 r = -EPROTO;
706 goto exit; 711 goto exit;
707 } 712 }
708 memcpy(target->sensf_res, nfcid1_skb->data, 713 memcpy(target->sensf_res, nfcid_skb->data,
709 nfcid1_skb->len); 714 nfcid_skb->len);
710 target->sensf_res_len = nfcid1_skb->len; 715 target->sensf_res_len = nfcid_skb->len;
711 target->supported_protocols = NFC_PROTO_NFC_DEP_MASK; 716 target->supported_protocols = NFC_PROTO_NFC_DEP_MASK;
712 } 717 }
713 target->hci_reader_gate = ST21NFCA_RF_READER_F_GATE; 718 target->hci_reader_gate = ST21NFCA_RF_READER_F_GATE;
714 } 719 }
715 r = 1; 720 r = 1;
716exit: 721exit:
717 kfree_skb(nfcid2_skb); 722 kfree_skb(nfcid_skb);
718 return r; 723 return r;
719} 724}
720 725