NFC: st21nfcb: Remove inappropriate kfree on a previously devm_kzalloc pointer
authorChristophe Ricard <christophe.ricard@gmail.com>
Mon, 28 Jul 2014 16:11:36 +0000 (18:11 +0200)
committerSamuel Ortiz <sameo@linux.intel.com>
Sun, 7 Sep 2014 21:56:48 +0000 (23:56 +0200)
In case of an error during driver probe, info pointer was freed with kfree.
No need to free anything when using devm_kzalloc.

Signed-off-by: Christophe Ricard <christophe-h.ricard@st.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
drivers/nfc/st21nfcb/st21nfcb.c

index 4d95863e30639f7e63c41cdcc066665eef988e65..64d2eaf40ef8be59c46896a2674e680070e3896c 100644 (file)
@@ -94,23 +94,18 @@ 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;
 
        nci_set_drvdata(ndlc->ndev, info);
 
        r = nci_register_device(ndlc->ndev);
-       if (r)
-               goto err_regdev;
-
-       return r;
-err_regdev:
-       nci_free_device(ndlc->ndev);
+       if (r) {
+               pr_err("Cannot register nfc device to nci core\n");
+               nci_free_device(ndlc->ndev);
+       }
 
-err_alloc_ndev:
-       kfree(info);
        return r;
 }
 EXPORT_SYMBOL_GPL(st21nfcb_nci_probe);