Skip to content

Commit dcf4214

Browse files
author
Bastien Nocera
committed
Bluetooth: hci_h5: Add ability to allocate memory for private data
JIRA: https://issues.redhat.com/browse/RHEL-33202 JIRA: https://issues.redhat.com/browse/RHEL-33203 CVE: CVE-2024-26890 commit 7a6d793 Author: Andrey Skvortsov <andrej.skvortzov@gmail.com> Date: Sat Feb 24 00:37:03 2024 +0300 Bluetooth: hci_h5: Add ability to allocate memory for private data In some cases uart-base drivers may need to use priv data. For example, to store information needed for devcoredump. Fixes: 044014c ("Bluetooth: btrtl: Add Realtek devcoredump support") Signed-off-by: Andrey Skvortsov <andrej.skvortzov@gmail.com> Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com> Signed-off-by: Bastien Nocera <bnocera@redhat.com>
1 parent ad86385 commit dcf4214

File tree

3 files changed

+19
-6
lines changed

3 files changed

+19
-6
lines changed

drivers/bluetooth/hci_h5.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ struct h5_vnd {
113113
int (*suspend)(struct h5 *h5);
114114
int (*resume)(struct h5 *h5);
115115
const struct acpi_gpio_mapping *acpi_gpio_map;
116+
int sizeof_priv;
116117
};
117118

118119
struct h5_device_data {
@@ -863,7 +864,8 @@ static int h5_serdev_probe(struct serdev_device *serdev)
863864
if (IS_ERR(h5->device_wake_gpio))
864865
return PTR_ERR(h5->device_wake_gpio);
865866

866-
return hci_uart_register_device(&h5->serdev_hu, &h5p);
867+
return hci_uart_register_device_priv(&h5->serdev_hu, &h5p,
868+
h5->vnd->sizeof_priv);
867869
}
868870

869871
static void h5_serdev_remove(struct serdev_device *serdev)

drivers/bluetooth/hci_serdev.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -300,8 +300,9 @@ static const struct serdev_device_ops hci_serdev_client_ops = {
300300
.write_wakeup = hci_uart_write_wakeup,
301301
};
302302

303-
int hci_uart_register_device(struct hci_uart *hu,
304-
const struct hci_uart_proto *p)
303+
int hci_uart_register_device_priv(struct hci_uart *hu,
304+
const struct hci_uart_proto *p,
305+
int sizeof_priv)
305306
{
306307
int err;
307308
struct hci_dev *hdev;
@@ -325,7 +326,7 @@ int hci_uart_register_device(struct hci_uart *hu,
325326
set_bit(HCI_UART_PROTO_READY, &hu->flags);
326327

327328
/* Initialize and register HCI device */
328-
hdev = hci_alloc_dev();
329+
hdev = hci_alloc_dev_priv(sizeof_priv);
329330
if (!hdev) {
330331
BT_ERR("Can't allocate HCI device");
331332
err = -ENOMEM;
@@ -394,7 +395,7 @@ int hci_uart_register_device(struct hci_uart *hu,
394395
percpu_free_rwsem(&hu->proto_lock);
395396
return err;
396397
}
397-
EXPORT_SYMBOL_GPL(hci_uart_register_device);
398+
EXPORT_SYMBOL_GPL(hci_uart_register_device_priv);
398399

399400
void hci_uart_unregister_device(struct hci_uart *hu)
400401
{

drivers/bluetooth/hci_uart.h

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,17 @@ struct hci_uart {
9797

9898
int hci_uart_register_proto(const struct hci_uart_proto *p);
9999
int hci_uart_unregister_proto(const struct hci_uart_proto *p);
100-
int hci_uart_register_device(struct hci_uart *hu, const struct hci_uart_proto *p);
100+
101+
int hci_uart_register_device_priv(struct hci_uart *hu,
102+
const struct hci_uart_proto *p,
103+
int sizeof_priv);
104+
105+
static inline int hci_uart_register_device(struct hci_uart *hu,
106+
const struct hci_uart_proto *p)
107+
{
108+
return hci_uart_register_device_priv(hu, p, 0);
109+
}
110+
101111
void hci_uart_unregister_device(struct hci_uart *hu);
102112

103113
int hci_uart_tx_wakeup(struct hci_uart *hu);

0 commit comments

Comments
 (0)