From: Sachin Kamat Date: Fri, 27 Jul 2012 07:08:37 +0000 (+0530) Subject: Bluetooth: Use devm_kzalloc in btsdio.c file X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=3a382772b51bbf55b23701746102bd75b9fe883f;p=linux-beck.git 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 Acked-by: Marcel Holtmann Signed-off-by: Gustavo Padovan --- diff --git a/drivers/bluetooth/btsdio.c b/drivers/bluetooth/btsdio.c index e10ea0347051..4a9909713874 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 = {