Bluetooth: Use devm_kzalloc in btsdio.c file

Linux-MTD Mailing List linux-mtd at lists.infradead.org
Sat Sep 29 10:59:25 EDT 2012


Gitweb:     http://git.infradead.org/?p=mtd-2.6.git;a=commit;h=3a382772b51bbf55b23701746102bd75b9fe883f
Commit:     3a382772b51bbf55b23701746102bd75b9fe883f
Parent:     eb17ea3b1ce6302e7416c4ba58754fd70ee3ab62
Author:     Sachin Kamat <sachin.kamat at linaro.org>
AuthorDate: Fri Jul 27 12:38:37 2012 +0530
Committer:  Gustavo Padovan <gustavo.padovan at collabora.co.uk>
CommitDate: Mon Aug 6 15:03:01 2012 -0300

    Bluetooth: Use devm_kzalloc in btsdio.c file
    
    devm_kzalloc() eliminates the need to free memory explicitly
    thereby saving some cleanup code.
    
    Signed-off-by: Sachin Kamat <sachin.kamat at linaro.org>
    Acked-by: Marcel Holtmann <marcel at holtmann.org>
    Signed-off-by: Gustavo Padovan <gustavo.padovan at collabora.co.uk>
---
 drivers/bluetooth/btsdio.c |    8 ++------
 1 files changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/bluetooth/btsdio.c b/drivers/bluetooth/btsdio.c
index e10ea03..4a99097 100644
--- a/drivers/bluetooth/btsdio.c
+++ b/drivers/bluetooth/btsdio.c
@@ -304,7 +304,7 @@ static int btsdio_probe(struct sdio_func *func,
 		tuple = tuple->next;
 	}
 
-	data = kzalloc(sizeof(*data), GFP_KERNEL);
+	data = devm_kzalloc(&func->dev, sizeof(*data), GFP_KERNEL);
 	if (!data)
 		return -ENOMEM;
 
@@ -315,10 +315,8 @@ static int btsdio_probe(struct sdio_func *func,
 	skb_queue_head_init(&data->txq);
 
 	hdev = hci_alloc_dev();
-	if (!hdev) {
-		kfree(data);
+	if (!hdev)
 		return -ENOMEM;
-	}
 
 	hdev->bus = HCI_SDIO;
 	hci_set_drvdata(hdev, data);
@@ -340,7 +338,6 @@ static int btsdio_probe(struct sdio_func *func,
 	err = hci_register_dev(hdev);
 	if (err < 0) {
 		hci_free_dev(hdev);
-		kfree(data);
 		return err;
 	}
 
@@ -366,7 +363,6 @@ static void btsdio_remove(struct sdio_func *func)
 	hci_unregister_dev(hdev);
 
 	hci_free_dev(hdev);
-	kfree(data);
 }
 
 static struct sdio_driver btsdio_driver = {



More information about the linux-mtd-cvs mailing list