Skip to content

Commit

Permalink
NFC: digital: Fix a memory leak in NFC-F listening mode
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Samuel Ortiz <[email protected]>
  • Loading branch information
Thierry Escande authored and Samuel Ortiz committed Jul 6, 2016
1 parent 8f49bec commit b776934
Showing 1 changed file with 1 addition and 10 deletions.
11 changes: 1 addition & 10 deletions net/nfc/digital_technology.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit b776934

Please sign in to comment.