diff options
author | Thierry Escande <thierry.escande@linux.intel.com> | 2014-02-12 08:27:51 -0500 |
---|---|---|
committer | Samuel Ortiz <sameo@linux.intel.com> | 2014-02-16 17:49:55 -0500 |
commit | 6ea7398d00345a33b47d905875416ca4421838de (patch) | |
tree | 53109341d092b714925e7b43f91516a1545443ef | |
parent | 564af14e36742f5900e40d48dcf30a3414acb143 (diff) |
NFC: digital: Fix a possible memory leak
This fixes a memory leak issue that may occur if data sending fails in
initiator mode. The data_exch structure was not released in case of
error.
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Thierry Escande <thierry.escande@linux.intel.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
-rw-r--r-- | net/nfc/digital_core.c | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/net/nfc/digital_core.c b/net/nfc/digital_core.c index 10146e703270..969a7f924a37 100644 --- a/net/nfc/digital_core.c +++ b/net/nfc/digital_core.c | |||
@@ -671,19 +671,27 @@ static int digital_in_send(struct nfc_dev *nfc_dev, struct nfc_target *target, | |||
671 | data_exch->cb = cb; | 671 | data_exch->cb = cb; |
672 | data_exch->cb_context = cb_context; | 672 | data_exch->cb_context = cb_context; |
673 | 673 | ||
674 | if (ddev->curr_protocol == NFC_PROTO_NFC_DEP) | 674 | if (ddev->curr_protocol == NFC_PROTO_NFC_DEP) { |
675 | return digital_in_send_dep_req(ddev, target, skb, data_exch); | 675 | rc = digital_in_send_dep_req(ddev, target, skb, data_exch); |
676 | goto exit; | ||
677 | } | ||
676 | 678 | ||
677 | if (ddev->curr_protocol == NFC_PROTO_ISO14443) { | 679 | if (ddev->curr_protocol == NFC_PROTO_ISO14443) { |
678 | rc = digital_in_iso_dep_push_sod(ddev, skb); | 680 | rc = digital_in_iso_dep_push_sod(ddev, skb); |
679 | if (rc) | 681 | if (rc) |
680 | return rc; | 682 | goto exit; |
681 | } | 683 | } |
682 | 684 | ||
683 | ddev->skb_add_crc(skb); | 685 | ddev->skb_add_crc(skb); |
684 | 686 | ||
685 | return digital_in_send_cmd(ddev, skb, 500, digital_in_send_complete, | 687 | rc = digital_in_send_cmd(ddev, skb, 500, digital_in_send_complete, |
686 | data_exch); | 688 | data_exch); |
689 | |||
690 | exit: | ||
691 | if (rc) | ||
692 | kfree(data_exch); | ||
693 | |||
694 | return rc; | ||
687 | } | 695 | } |
688 | 696 | ||
689 | static struct nfc_ops digital_nfc_ops = { | 697 | static struct nfc_ops digital_nfc_ops = { |