提交 c6dc65d8 编写于 作者: D Dan Carpenter 提交者: Samuel Ortiz

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: caa575a8 ('NFC: nci: fix possible crash in nci_core_conn_create')
Acked-by: NChristophe Ricard <christophe-h.ricard@st.com>
Signed-off-by: NDan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: NSamuel Ortiz <sameo@linux.intel.com>
上级 97b69788
......@@ -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);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册