diff options
author | Amitkumar Karwar <akarwar@marvell.com> | 2014-01-08 10:52:27 -0800 |
---|---|---|
committer | Samuel Ortiz <sameo@linux.intel.com> | 2014-01-09 01:27:20 +0100 |
commit | bb55dc2ae4367b8f711d43a2f8668a6ed42c4fd3 (patch) | |
tree | 48417a9794a29f28b9870c4279a1e3547b96cf8a /drivers/nfc | |
parent | b711ad524bf5a6a078c4d0a1a44ca1db204802f6 (diff) | |
download | linux-stable-bb55dc2ae4367b8f711d43a2f8668a6ed42c4fd3.tar.gz linux-stable-bb55dc2ae4367b8f711d43a2f8668a6ed42c4fd3.tar.bz2 linux-stable-bb55dc2ae4367b8f711d43a2f8668a6ed42c4fd3.zip |
NFC: nfcmrvl: Fix possible memory leak issue
This patch fixes memory leaks in the error paths of
nfcmrvl_nci_register_dev() routine.
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Amitkumar Karwar <akarwar@marvell.com>
Signed-off-by: Bing Zhao <bzhao@marvell.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
Diffstat (limited to 'drivers/nfc')
-rw-r--r-- | drivers/nfc/nfcmrvl/main.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/drivers/nfc/nfcmrvl/main.c b/drivers/nfc/nfcmrvl/main.c index 5f91d4571429..85e8bcf98693 100644 --- a/drivers/nfc/nfcmrvl/main.c +++ b/drivers/nfc/nfcmrvl/main.c @@ -112,7 +112,8 @@ struct nfcmrvl_private *nfcmrvl_nci_register_dev(void *drv_data, priv->ndev = nci_allocate_device(&nfcmrvl_nci_ops, protocols, 0, 0); if (!priv->ndev) { nfc_err(dev, "nci_allocate_device failed"); - return ERR_PTR(-ENOMEM); + rc = -ENOMEM; + goto error; } nci_set_drvdata(priv->ndev, priv); @@ -121,11 +122,15 @@ struct nfcmrvl_private *nfcmrvl_nci_register_dev(void *drv_data, if (rc) { nfc_err(dev, "nci_register_device failed %d", rc); nci_free_device(priv->ndev); - return ERR_PTR(rc); + goto error; } nfc_info(dev, "registered with nci successfully\n"); return priv; + +error: + kfree(priv); + return ERR_PTR(rc); } EXPORT_SYMBOL_GPL(nfcmrvl_nci_register_dev); |