Skip to contentSkip to conversation

NFC: st21nfcb: double free on allocation error

PATCH New Dan Carpenter 1 participant 1 message Jul 31, 2014

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 NFC: st21nfcb: double free on allocation error

"info" is allocated with devm_kzalloc() so calling kfree() here will lead to a double free.

drivers/nfc/st21nfcb/st21nfcb.c +1 -4
index 4d95863..6944f9e 100644
@@ -94,8 +94,7 @@ int st21nfcb_nci_probe(struct llt_ndlc *ndlc, int phy_headroom,
 					phy_headroom, phy_tailroom);
 	if (!ndlc->ndev) {
 		pr_err("Cannot allocate nfc ndev\n");
-		r = -ENOMEM;
-		goto err_alloc_ndev;
+		return -ENOMEM;
 	}
 	info->ndlc = ndlc;
 
@@ -109,8 +108,6 @@ int st21nfcb_nci_probe(struct llt_ndlc *ndlc, int phy_headroom,
 err_regdev:
 	nci_free_device(ndlc->ndev);
 
-err_alloc_ndev:
-	kfree(info);
 	return r;
 }
 EXPORT_SYMBOL_GPL(st21nfcb_nci_probe);