Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Bluetooth: Use devm_kzalloc in bfusb.c file

devm_kzalloc() eliminates the need to free memory explicitly
thereby saving some cleanup code.

Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>

authored by

Sachin Kamat and committed by
Gustavo Padovan
0213cd8d 9357cc60

+4 -8
+4 -8
drivers/bluetooth/bfusb.c
··· 653 653 } 654 654 655 655 /* Initialize control structure and load firmware */ 656 - data = kzalloc(sizeof(struct bfusb_data), GFP_KERNEL); 656 + data = devm_kzalloc(&intf->dev, sizeof(struct bfusb_data), GFP_KERNEL); 657 657 if (!data) { 658 658 BT_ERR("Can't allocate memory for control structure"); 659 659 goto done; ··· 674 674 675 675 if (request_firmware(&firmware, "bfubase.frm", &udev->dev) < 0) { 676 676 BT_ERR("Firmware request failed"); 677 - goto error; 677 + goto done; 678 678 } 679 679 680 680 BT_DBG("firmware data %p size %zu", firmware->data, firmware->size); ··· 690 690 hdev = hci_alloc_dev(); 691 691 if (!hdev) { 692 692 BT_ERR("Can't allocate HCI device"); 693 - goto error; 693 + goto done; 694 694 } 695 695 696 696 data->hdev = hdev; ··· 708 708 if (hci_register_dev(hdev) < 0) { 709 709 BT_ERR("Can't register HCI device"); 710 710 hci_free_dev(hdev); 711 - goto error; 711 + goto done; 712 712 } 713 713 714 714 usb_set_intfdata(intf, data); ··· 717 717 718 718 release: 719 719 release_firmware(firmware); 720 - 721 - error: 722 - kfree(data); 723 720 724 721 done: 725 722 return -EIO; ··· 738 741 739 742 hci_unregister_dev(hdev); 740 743 hci_free_dev(hdev); 741 - kfree(data); 742 744 } 743 745 744 746 static struct usb_driver bfusb_driver = {