mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Robert Dolca <robert.dolca@intel.com>
To: linux-nfc@ml01.01.org,
	Lauro Ramos Venancio <lauro.venancio@openbossa.org>,
	Aloisio Almeida Jr <aloisio.almeida@openbossa.org>,
	Samuel Ortiz <sameo@linux.intel.com>,
	Robert Dolca <robert.dolca@gmail.com>
Cc: linux-kernel@vger.kernel.org, linux-wireless@vger.kernel.org,
	netdev@vger.kernel.org,
	Christophe Ricard <christophe.ricard@gmail.com>,
	Robert Dolca <robert.dolca@intel.com>
Subject: [PATCH v4 08/10] nfc: nci: fix possible crash in nci_core_conn_create
Date: Thu, 22 Oct 2015 12:11:40 +0300	[thread overview]
Message-ID: <1445505102-16639-9-git-send-email-robert.dolca@intel.com> (raw)
In-Reply-To: <1445505102-16639-1-git-send-email-robert.dolca@intel.com>

If the number of destination speific parameters supplied is 0 the call
will fail. If the first destination specific parameter does not have a
value, curr_id will be set to 0.

Signed-off-by: Robert Dolca <robert.dolca@intel.com>
---
 net/nfc/nci/core.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/net/nfc/nci/core.c b/net/nfc/nci/core.c
index f66a5da..9d5f7a2 100644
--- a/net/nfc/nci/core.c
+++ b/net/nfc/nci/core.c
@@ -602,12 +602,19 @@ int nci_core_conn_create(struct nci_dev *ndev, u8 destination_type,
 	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);
 
 	data.cmd = cmd;
-	ndev->cur_id = params->value[DEST_SPEC_PARAMS_ID_INDEX];
+
+	if (params->length > 0)
+		ndev->cur_id = params->value[DEST_SPEC_PARAMS_ID_INDEX];
+	else
+		ndev->cur_id = 0;
 
 	r = __nci_request(ndev, nci_core_conn_create_req,
 			  (unsigned long)&data,
-- 
1.9.1


  parent reply	other threads:[~2015-10-22  9:13 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-22  9:11 [PATCH v4 00/10] Add Intel FieldsPeak NFC solution driver Robert Dolca
2015-10-22  9:11 ` [PATCH v4 01/10] nfc: nci: Export nci data send API Robert Dolca
2015-10-22  9:11 ` [PATCH v4 02/10] nfc: nci: Add function to get max packet size for conn Robert Dolca
2015-10-22  9:11 ` [PATCH v4 03/10] nfc: nci: Introduce new core opcodes Robert Dolca
2015-10-22  9:11 ` [PATCH v4 04/10] nfc: nci: Do not call post_setup when setup fails Robert Dolca
2015-10-22  9:11 ` [PATCH v4 05/10] nfc: nci: Introduce nci_core_cmd Robert Dolca
2015-10-22  9:11 ` [PATCH v4 06/10] nfc: nci: Allow the driver to set handler for core nci ops Robert Dolca
2015-10-22  9:11 ` [PATCH v4 07/10] nfc: nci: rename nci_prop_ops to nci_driver_ops Robert Dolca
2015-10-22  9:11 ` Robert Dolca [this message]
2015-10-22  9:11 ` [PATCH v4 09/10] nfc: nci: add nci_get_conn_info_by_id function Robert Dolca
2015-10-22  9:11 ` [PATCH v4 10/10] nfc: Add Intel Fields Peak NFC solution driver Robert Dolca

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1445505102-16639-9-git-send-email-robert.dolca@intel.com \
    --to=robert.dolca@intel.com \
    --cc=aloisio.almeida@openbossa.org \
    --cc=christophe.ricard@gmail.com \
    --cc=lauro.venancio@openbossa.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-nfc@ml01.01.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=robert.dolca@gmail.com \
    --cc=sameo@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome