Skip to content

Commit 0213cd8

Browse files
Sachin KamatGustavo Padovan
authored andcommitted
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>
1 parent 9357cc6 commit 0213cd8

1 file changed

Lines changed: 4 additions & 8 deletions

File tree

‎drivers/bluetooth/bfusb.c‎

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -653,7 +653,7 @@ static int bfusb_probe(struct usb_interface *intf, const struct usb_device_id *i
653653
}
654654

655655
/* 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);
657657
if (!data) {
658658
BT_ERR("Can't allocate memory for control structure");
659659
goto done;
@@ -674,7 +674,7 @@ static int bfusb_probe(struct usb_interface *intf, const struct usb_device_id *i
674674

675675
if (request_firmware(&firmware, "bfubase.frm", &udev->dev) < 0) {
676676
BT_ERR("Firmware request failed");
677-
goto error;
677+
goto done;
678678
}
679679

680680
BT_DBG("firmware data %p size %zu", firmware->data, firmware->size);
@@ -690,7 +690,7 @@ static int bfusb_probe(struct usb_interface *intf, const struct usb_device_id *i
690690
hdev = hci_alloc_dev();
691691
if (!hdev) {
692692
BT_ERR("Can't allocate HCI device");
693-
goto error;
693+
goto done;
694694
}
695695

696696
data->hdev = hdev;
@@ -708,7 +708,7 @@ static int bfusb_probe(struct usb_interface *intf, const struct usb_device_id *i
708708
if (hci_register_dev(hdev) < 0) {
709709
BT_ERR("Can't register HCI device");
710710
hci_free_dev(hdev);
711-
goto error;
711+
goto done;
712712
}
713713

714714
usb_set_intfdata(intf, data);
@@ -718,9 +718,6 @@ static int bfusb_probe(struct usb_interface *intf, const struct usb_device_id *i
718718
release:
719719
release_firmware(firmware);
720720

721-
error:
722-
kfree(data);
723-
724721
done:
725722
return -EIO;
726723
}
@@ -741,7 +738,6 @@ static void bfusb_disconnect(struct usb_interface *intf)
741738

742739
hci_unregister_dev(hdev);
743740
hci_free_dev(hdev);
744-
kfree(data);
745741
}
746742

747743
static struct usb_driver bfusb_driver = {

0 commit comments

Comments
 (0)