summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulia Lawall <Julia.Lawall@lip6.fr>2012-12-06 23:10:40 +0100
committerJohn W. Linville <linville@tuxdriver.com>2013-01-11 14:49:57 -0500
commit29b7d9ad9112a95757c8030421dc3bd1b28ad8b5 (patch)
treeae02dc7909e80c37aff87222fd9e99270a3e3839
parente93d083f42a126b5ad8137b5f0e8d6f900b332b8 (diff)
drivers/nfc/nfcwilink.c: use devm_kzalloc
devm_kzalloc allocates memory that is released when a driver detaches. This patch uses devm_kzalloc for data that is allocated in the probe function of a platform device and is only freed in the remove function. Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr> Signed-off-by: John W. Linville <linville@tuxdriver.com>
-rw-r--r--drivers/nfc/nfcwilink.c9
1 files changed, 2 insertions, 7 deletions
diff --git a/drivers/nfc/nfcwilink.c b/drivers/nfc/nfcwilink.c
index 50b1ee41afc6..c7c182d2b7df 100644
--- a/drivers/nfc/nfcwilink.c
+++ b/drivers/nfc/nfcwilink.c
@@ -526,7 +526,7 @@ static int nfcwilink_probe(struct platform_device *pdev)
nfc_dev_dbg(&pdev->dev, "probe entry");
- drv = kzalloc(sizeof(struct nfcwilink), GFP_KERNEL);
+ drv = devm_kzalloc(&pdev->dev, sizeof(struct nfcwilink), GFP_KERNEL);
if (!drv) {
rc = -ENOMEM;
goto exit;
@@ -547,7 +547,7 @@ static int nfcwilink_probe(struct platform_device *pdev)
if (!drv->ndev) {
nfc_dev_err(&pdev->dev, "nci_allocate_device failed");
rc = -ENOMEM;
- goto free_exit;
+ goto exit;
}
nci_set_parent_dev(drv->ndev, &pdev->dev);
@@ -566,9 +566,6 @@ static int nfcwilink_probe(struct platform_device *pdev)
free_dev_exit:
nci_free_device(drv->ndev);
-free_exit:
- kfree(drv);
-
exit:
return rc;
}
@@ -588,8 +585,6 @@ static int nfcwilink_remove(struct platform_device *pdev)
nci_unregister_device(ndev);
nci_free_device(ndev);
- kfree(drv);
-
dev_set_drvdata(&pdev->dev, NULL);
return 0;