Skip to content

Commit 1a609a0

Browse files
David Herrmannjhedberg
authored andcommitted
Bluetooth: bfusb: Free driver_data on USB shutdown
This frees the private driver data on USB shutdown instead of using the hci-destruct callback. We already call usb_set_intfdata(intf, NULL) but we do not do the same with the hci object. This would be totally safe, though. After calling hci_unregister_dev()/hci_free_dev() the hdev object will never call any callback of us again except the destruct callback. Therefore, we can safely set the destruct callback to NULL and free the driver data right away. This allows to unload the module without waiting for the hdev device to be released. Signed-off-by: David Herrmann <dh.herrmann@googlemail.com> Acked-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
1 parent bf18c71 commit 1a609a0

1 file changed

Lines changed: 1 addition & 10 deletions

File tree

‎drivers/bluetooth/bfusb.c‎

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -544,15 +544,6 @@ static int bfusb_send_frame(struct sk_buff *skb)
544544
return 0;
545545
}
546546

547-
static void bfusb_destruct(struct hci_dev *hdev)
548-
{
549-
struct bfusb_data *data = hdev->driver_data;
550-
551-
BT_DBG("hdev %p bfusb %p", hdev, data);
552-
553-
kfree(data);
554-
}
555-
556547
static int bfusb_ioctl(struct hci_dev *hdev, unsigned int cmd, unsigned long arg)
557548
{
558549
return -ENOIOCTLCMD;
@@ -712,7 +703,6 @@ static int bfusb_probe(struct usb_interface *intf, const struct usb_device_id *i
712703
hdev->close = bfusb_close;
713704
hdev->flush = bfusb_flush;
714705
hdev->send = bfusb_send_frame;
715-
hdev->destruct = bfusb_destruct;
716706
hdev->ioctl = bfusb_ioctl;
717707

718708
hdev->owner = THIS_MODULE;
@@ -753,6 +743,7 @@ static void bfusb_disconnect(struct usb_interface *intf)
753743

754744
hci_unregister_dev(hdev);
755745
hci_free_dev(hdev);
746+
kfree(data);
756747
}
757748

758749
static struct usb_driver bfusb_driver = {

0 commit comments

Comments
 (0)