NFC: digital: Fix a memory leak in NFC-F listening mode

When configured as a target listening for a SENSF_REQ poll command, a
nfcid2 array was allocated for no reason leading to a memory leak. The
nfcid2 is sent by the target in the SENSF_RES reply.

Signed-off-by: Thierry Escande <thierry.escande@collabora.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
This commit is contained in:
Thierry Escande 2016-06-16 20:24:41 +02:00 committed by Samuel Ortiz
parent 8f49bec6c3
commit b77693447d
1 changed files with 1 additions and 10 deletions

View File

@ -1257,21 +1257,12 @@ static int digital_tg_config_nfcf(struct nfc_digital_dev *ddev, u8 rf_tech)
int digital_tg_listen_nfcf(struct nfc_digital_dev *ddev, u8 rf_tech)
{
int rc;
u8 *nfcid2;
rc = digital_tg_config_nfcf(ddev, rf_tech);
if (rc)
return rc;
nfcid2 = kzalloc(NFC_NFCID2_MAXSIZE, GFP_KERNEL);
if (!nfcid2)
return -ENOMEM;
nfcid2[0] = DIGITAL_SENSF_NFCID2_NFC_DEP_B1;
nfcid2[1] = DIGITAL_SENSF_NFCID2_NFC_DEP_B2;
get_random_bytes(nfcid2 + 2, NFC_NFCID2_MAXSIZE - 2);
return digital_tg_listen(ddev, 300, digital_tg_recv_sensf_req, nfcid2);
return digital_tg_listen(ddev, 300, digital_tg_recv_sensf_req, NULL);
}
void digital_tg_recv_md_req(struct nfc_digital_dev *ddev, void *arg,