summaryrefslogtreecommitdiffstats
path: root/net/nfc
diff options
context:
space:
mode:
authorDan Carpenter <dan.carpenter@oracle.com>2015-12-23 17:45:27 -0500
committerSamuel Ortiz <sameo@linux.intel.com>2015-12-29 13:06:23 -0500
commitc6dc65d885b98898bf287aaf44e020077b41769f (patch)
tree94d8c0d3eaecb7589469b9dc6066445c2a1b57ab /net/nfc
parent97b69788971de8af994ba570d56c455e79eaf35e (diff)
NFC: nci: memory leak in nci_core_conn_create()
I've moved the check for "number_destination_params" forward a few lines to avoid leaking "cmd". Fixes: caa575a86ec1 ('NFC: nci: fix possible crash in nci_core_conn_create') Acked-by: Christophe Ricard <christophe-h.ricard@st.com> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Diffstat (limited to 'net/nfc')
-rw-r--r--net/nfc/nci/core.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/net/nfc/nci/core.c b/net/nfc/nci/core.c
index 10c99a578421..fbb7a2b57b44 100644
--- a/net/nfc/nci/core.c
+++ b/net/nfc/nci/core.c
@@ -610,14 +610,14 @@ int nci_core_conn_create(struct nci_dev *ndev, u8 destination_type,
610 struct nci_core_conn_create_cmd *cmd; 610 struct nci_core_conn_create_cmd *cmd;
611 struct core_conn_create_data data; 611 struct core_conn_create_data data;
612 612
613 if (!number_destination_params)
614 return -EINVAL;
615
613 data.length = params_len + sizeof(struct nci_core_conn_create_cmd); 616 data.length = params_len + sizeof(struct nci_core_conn_create_cmd);
614 cmd = kzalloc(data.length, GFP_KERNEL); 617 cmd = kzalloc(data.length, GFP_KERNEL);
615 if (!cmd) 618 if (!cmd)
616 return -ENOMEM; 619 return -ENOMEM;
617 620
618 if (!number_destination_params)
619 return -EINVAL;
620
621 cmd->destination_type = destination_type; 621 cmd->destination_type = destination_type;
622 cmd->number_destination_params = number_destination_params; 622 cmd->number_destination_params = number_destination_params;
623 memcpy(cmd->params, params, params_len); 623 memcpy(cmd->params, params, params_len);