Skip to content

Commit

Permalink
NFC: nfcwilink: Use devm_kzalloc
Browse files Browse the repository at this point in the history
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: Samuel Ortiz <sameo@linux.intel.com>
  • Loading branch information
Julia Lawall authored and Samuel Ortiz committed Jan 9, 2013
1 parent 9e2d493 commit 5f4d621
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions drivers/nfc/nfcwilink.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand All @@ -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;
}
Expand All @@ -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;
Expand Down

0 comments on commit 5f4d621

Please sign in to comment.