linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [patch] NFC: nci: memory leak in nci_core_conn_create()
@ 2015-11-04 13:37 Dan Carpenter
  0 siblings, 0 replies; only message in thread
From: Dan Carpenter @ 2015-11-04 13:37 UTC (permalink / raw)
  To: Lauro Ramos Venancio, Robert Dolca
  Cc: Aloisio Almeida Jr, Samuel Ortiz, Christophe Ricard,
	Julien Lefrique, Robert Baldyga, linux-wireless, kernel-janitors

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')
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

diff --git a/net/nfc/nci/core.c b/net/nfc/nci/core.c
index 10c99a5..fbb7a2b 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,
 	struct nci_core_conn_create_cmd *cmd;
 	struct core_conn_create_data data;
 
+	if (!number_destination_params)
+		return -EINVAL;
+
 	data.length = params_len + sizeof(struct nci_core_conn_create_cmd);
 	cmd = kzalloc(data.length, GFP_KERNEL);
 	if (!cmd)
 		return -ENOMEM;
 
-	if (!number_destination_params)
-		return -EINVAL;
-
 	cmd->destination_type = destination_type;
 	cmd->number_destination_params = number_destination_params;
 	memcpy(cmd->params, params, params_len);

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2015-11-04 13:37 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-11-04 13:37 [patch] NFC: nci: memory leak in nci_core_conn_create() Dan Carpenter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).