mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-01-11 17:10:13 +00:00
Bluetooth: btusb: revert use of devm_kzalloc in btusb
This reverts commit 98921dbd00c4e ("Bluetooth: Use devm_kzalloc in
btusb.c file").
In btusb_probe(), we use devm_kzalloc() to allocate the btusb data. This
ties the lifetime of all the btusb data to the binding of a driver to
one interface, INTF. In a driver that binds to other interfaces, ISOC
and DIAG, this is an accident waiting to happen.
The issue is revealed in btusb_disconnect(), where calling
usb_driver_release_interface(&btusb_driver, data->intf) will have devm
free the data that is also being used by the other interfaces of the
driver that may not be released yet.
To fix this, revert the use of devm and go back to freeing memory
explicitly.
Fixes: 98921dbd00c4e ("Bluetooth: Use devm_kzalloc in btusb.c file")
Signed-off-by: Raphael Pinsonneault-Thibeault <rpthibeault@gmail.com>
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
This commit is contained in:
parent
348240e5fa
commit
252714f1e8
@ -4052,7 +4052,7 @@ static int btusb_probe(struct usb_interface *intf,
|
|||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
}
|
}
|
||||||
|
|
||||||
data = devm_kzalloc(&intf->dev, sizeof(*data), GFP_KERNEL);
|
data = kzalloc(sizeof(*data), GFP_KERNEL);
|
||||||
if (!data)
|
if (!data)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
@ -4075,8 +4075,10 @@ 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;
|
||||||
|
}
|
||||||
|
|
||||||
if (id->driver_info & BTUSB_AMP) {
|
if (id->driver_info & BTUSB_AMP) {
|
||||||
data->cmdreq_type = USB_TYPE_CLASS | 0x01;
|
data->cmdreq_type = USB_TYPE_CLASS | 0x01;
|
||||||
@ -4131,8 +4133,10 @@ static int btusb_probe(struct usb_interface *intf,
|
|||||||
data->recv_acl = hci_recv_frame;
|
data->recv_acl = hci_recv_frame;
|
||||||
|
|
||||||
hdev = hci_alloc_dev_priv(priv_size);
|
hdev = hci_alloc_dev_priv(priv_size);
|
||||||
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);
|
||||||
@ -4406,6 +4410,7 @@ out_free_dev:
|
|||||||
if (data->reset_gpio)
|
if (data->reset_gpio)
|
||||||
gpiod_put(data->reset_gpio);
|
gpiod_put(data->reset_gpio);
|
||||||
hci_free_dev(hdev);
|
hci_free_dev(hdev);
|
||||||
|
kfree(data);
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4454,6 +4459,7 @@ static void btusb_disconnect(struct usb_interface *intf)
|
|||||||
}
|
}
|
||||||
|
|
||||||
hci_free_dev(hdev);
|
hci_free_dev(hdev);
|
||||||
|
kfree(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_PM
|
#ifdef CONFIG_PM
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user