Skip to contentSkip to conversation

NFC: st21nfca: fix double free

PATCH In review Pan Bian 2 participants 2 messages Nov 7, 2019

Subsystems (3)
lore
Share & tools
lore

Pan Bian

author
#0 lore raw

PATCH 1/1 NFC: st21nfca: fix double free

The variable nfcid_skb is not changed in the callee nfc_hci_get_param() if error occurs. Consequently, the freed variable nfcid_skb will be freed again, resulting in a double free bug. Set nfcid_skb to NULL after releasing it to fix the bug.

---
 drivers/nfc/st21nfca/core.c | 1 +
 1 file changed, 1 insertion(+)
drivers/nfc/st21nfca/core.c +1 -0
index f9ac176cf257..2ce17932a073 100644
@@ -708,6 +708,7 @@ static int st21nfca_hci_complete_target_discovered(struct nfc_hci_dev *hdev,
 							NFC_PROTO_FELICA_MASK;
 		} else {
 			kfree_skb(nfcid_skb);
+			nfcid_skb = NULL;
 			/* P2P in type A */
 			r = nfc_hci_get_param(hdev, ST21NFCA_RF_READER_F_GATE,
 					ST21NFCA_RF_READER_F_NFCID1,
Signature · 1 line
2.7.4
maintainer
#1 lore raw

From: Pan Bian <[email protected]>
Date: Thu, 7 Nov 2019 09:33:20 +0800

Quoted 6 lines

The variable nfcid_skb is not changed in the callee nfc_hci_get_param() if error occurs. Consequently, the freed variable nfcid_skb will be freed again, resulting in a double free bug. Set nfcid_skb to NULL after releasing it to fix the bug.

Applied and queued up for -stable.