Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Thierry Escande and committed by
Samuel Ortiz
b7769344 8f49bec6

+1 -10
+1 -10
net/nfc/digital_technology.c
··· 1257 1257 int digital_tg_listen_nfcf(struct nfc_digital_dev *ddev, u8 rf_tech) 1258 1258 { 1259 1259 int rc; 1260 - u8 *nfcid2; 1261 1260 1262 1261 rc = digital_tg_config_nfcf(ddev, rf_tech); 1263 1262 if (rc) 1264 1263 return rc; 1265 1264 1266 - nfcid2 = kzalloc(NFC_NFCID2_MAXSIZE, GFP_KERNEL); 1267 - if (!nfcid2) 1268 - return -ENOMEM; 1269 - 1270 - nfcid2[0] = DIGITAL_SENSF_NFCID2_NFC_DEP_B1; 1271 - nfcid2[1] = DIGITAL_SENSF_NFCID2_NFC_DEP_B2; 1272 - get_random_bytes(nfcid2 + 2, NFC_NFCID2_MAXSIZE - 2); 1273 - 1274 - return digital_tg_listen(ddev, 300, digital_tg_recv_sensf_req, nfcid2); 1265 + return digital_tg_listen(ddev, 300, digital_tg_recv_sensf_req, NULL); 1275 1266 } 1276 1267 1277 1268 void digital_tg_recv_md_req(struct nfc_digital_dev *ddev, void *arg,