Commit 98921dbd authored by Sachin Kamat's avatar Sachin Kamat Committed by Gustavo Padovan

Bluetooth: Use devm_kzalloc in btusb.c file

devm_kzalloc() eliminates the need to free memory explicitly
thereby saving some cleanup code.
Signed-off-by: default avatarSachin Kamat <sachin.kamat@linaro.org>
Acked-by: default avatarMarcel Holtmann <marcel@holtmann.org>
Signed-off-by: default avatarGustavo Padovan <gustavo.padovan@collabora.co.uk>
parent fdefa118
...@@ -952,7 +952,7 @@ static int btusb_probe(struct usb_interface *intf, ...@@ -952,7 +952,7 @@ static int btusb_probe(struct usb_interface *intf,
return -ENODEV; return -ENODEV;
} }
data = kzalloc(sizeof(*data), GFP_KERNEL); data = devm_kzalloc(&intf->dev, sizeof(*data), GFP_KERNEL);
if (!data) if (!data)
return -ENOMEM; return -ENOMEM;
...@@ -975,10 +975,8 @@ static int btusb_probe(struct usb_interface *intf, ...@@ -975,10 +975,8 @@ static int btusb_probe(struct usb_interface *intf,
} }
} }
if (!data->intr_ep || !data->bulk_tx_ep || !data->bulk_rx_ep) { if (!data->intr_ep || !data->bulk_tx_ep || !data->bulk_rx_ep)
kfree(data);
return -ENODEV; return -ENODEV;
}
data->cmdreq_type = USB_TYPE_CLASS; data->cmdreq_type = USB_TYPE_CLASS;
...@@ -998,10 +996,8 @@ static int btusb_probe(struct usb_interface *intf, ...@@ -998,10 +996,8 @@ static int btusb_probe(struct usb_interface *intf,
init_usb_anchor(&data->deferred); init_usb_anchor(&data->deferred);
hdev = hci_alloc_dev(); hdev = hci_alloc_dev();
if (!hdev) { if (!hdev)
kfree(data);
return -ENOMEM; return -ENOMEM;
}
hdev->bus = HCI_USB; hdev->bus = HCI_USB;
hci_set_drvdata(hdev, data); hci_set_drvdata(hdev, data);
...@@ -1069,7 +1065,6 @@ static int btusb_probe(struct usb_interface *intf, ...@@ -1069,7 +1065,6 @@ static int btusb_probe(struct usb_interface *intf,
data->isoc, data); data->isoc, data);
if (err < 0) { if (err < 0) {
hci_free_dev(hdev); hci_free_dev(hdev);
kfree(data);
return err; return err;
} }
} }
...@@ -1077,7 +1072,6 @@ static int btusb_probe(struct usb_interface *intf, ...@@ -1077,7 +1072,6 @@ static int btusb_probe(struct usb_interface *intf,
err = hci_register_dev(hdev); err = hci_register_dev(hdev);
if (err < 0) { if (err < 0) {
hci_free_dev(hdev); hci_free_dev(hdev);
kfree(data);
return err; return err;
} }
...@@ -1110,7 +1104,6 @@ static void btusb_disconnect(struct usb_interface *intf) ...@@ -1110,7 +1104,6 @@ static void btusb_disconnect(struct usb_interface *intf)
usb_driver_release_interface(&btusb_driver, data->isoc); usb_driver_release_interface(&btusb_driver, data->isoc);
hci_free_dev(hdev); hci_free_dev(hdev);
kfree(data);
} }
#ifdef CONFIG_PM #ifdef CONFIG_PM
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment