Commit 29b7d9ad authored by Julia Lawall's avatar Julia Lawall Committed by John W. Linville

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: default avatarJulia Lawall <Julia.Lawall@lip6.fr>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent e93d083f
...@@ -526,7 +526,7 @@ static int nfcwilink_probe(struct platform_device *pdev) ...@@ -526,7 +526,7 @@ static int nfcwilink_probe(struct platform_device *pdev)
nfc_dev_dbg(&pdev->dev, "probe entry"); 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) { if (!drv) {
rc = -ENOMEM; rc = -ENOMEM;
goto exit; goto exit;
...@@ -547,7 +547,7 @@ static int nfcwilink_probe(struct platform_device *pdev) ...@@ -547,7 +547,7 @@ static int nfcwilink_probe(struct platform_device *pdev)
if (!drv->ndev) { if (!drv->ndev) {
nfc_dev_err(&pdev->dev, "nci_allocate_device failed"); nfc_dev_err(&pdev->dev, "nci_allocate_device failed");
rc = -ENOMEM; rc = -ENOMEM;
goto free_exit; goto exit;
} }
nci_set_parent_dev(drv->ndev, &pdev->dev); nci_set_parent_dev(drv->ndev, &pdev->dev);
...@@ -566,9 +566,6 @@ static int nfcwilink_probe(struct platform_device *pdev) ...@@ -566,9 +566,6 @@ static int nfcwilink_probe(struct platform_device *pdev)
free_dev_exit: free_dev_exit:
nci_free_device(drv->ndev); nci_free_device(drv->ndev);
free_exit:
kfree(drv);
exit: exit:
return rc; return rc;
} }
...@@ -588,8 +585,6 @@ static int nfcwilink_remove(struct platform_device *pdev) ...@@ -588,8 +585,6 @@ static int nfcwilink_remove(struct platform_device *pdev)
nci_unregister_device(ndev); nci_unregister_device(ndev);
nci_free_device(ndev); nci_free_device(ndev);
kfree(drv);
dev_set_drvdata(&pdev->dev, NULL); dev_set_drvdata(&pdev->dev, NULL);
return 0; return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment