Skip to content

Commit

Permalink
nfc: nci: Fix nci_core_conn_create to allowing empty destination
Browse files Browse the repository at this point in the history
NCI_CORE_CONN_CREATE may not have any destination type parameter.

Signed-off-by: Christophe Ricard <[email protected]>
Signed-off-by: Samuel Ortiz <[email protected]>
  • Loading branch information
cricard13 authored and Samuel Ortiz committed May 3, 2016
1 parent 99adc39 commit 1883602
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions net/nfc/nci/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -610,27 +610,27 @@ 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;

cmd->destination_type = destination_type;
cmd->number_destination_params = number_destination_params;
memcpy(cmd->params, params, params_len);

data.cmd = cmd;

if (params->length > 0)
ndev->cur_id = params->value[DEST_SPEC_PARAMS_ID_INDEX];
else
if (params) {
memcpy(cmd->params, params, params_len);
if (params->length > 0)
ndev->cur_id = params->value[DEST_SPEC_PARAMS_ID_INDEX];
else
ndev->cur_id = 0;
} else {
ndev->cur_id = 0;
}

r = __nci_request(ndev, nci_core_conn_create_req,
(unsigned long)&data,
r = __nci_request(ndev, nci_core_conn_create_req, (unsigned long)&data,
msecs_to_jiffies(NCI_CMD_TIMEOUT));
kfree(cmd);
return r;
Expand Down

0 comments on commit 1883602

Please sign in to comment.