Skip to content

Commit 244b96c

Browse files
committed
Merge tag 'for-net-2024-02-28' of git://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth
Luiz Augusto von Dentz says: ==================== bluetooth pull request for net: - mgmt: Fix limited discoverable off timeout - hci_qca: Set BDA quirk bit if fwnode exists in DT - hci_bcm4377: do not mark valid bd_addr as invalid - hci_sync: Check the correct flag before starting a scan - Enforce validation on max value of connection interval - hci_sync: Fix accept_list when attempting to suspend - hci_event: Fix handling of HCI_EV_IO_CAPA_REQUEST - Avoid potential use-after-free in hci_error_reset - rfcomm: Fix null-ptr-deref in rfcomm_check_security - hci_event: Fix wrongly recorded wakeup BD_ADDR - qca: Fix wrong event type for patch config command - qca: Fix triggering coredump implementation * tag 'for-net-2024-02-28' of git://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth: Bluetooth: qca: Fix triggering coredump implementation Bluetooth: hci_qca: Set BDA quirk bit if fwnode exists in DT Bluetooth: qca: Fix wrong event type for patch config command Bluetooth: Enforce validation on max value of connection interval Bluetooth: hci_event: Fix handling of HCI_EV_IO_CAPA_REQUEST Bluetooth: mgmt: Fix limited discoverable off timeout Bluetooth: hci_event: Fix wrongly recorded wakeup BD_ADDR Bluetooth: rfcomm: Fix null-ptr-deref in rfcomm_check_security Bluetooth: hci_sync: Fix accept_list when attempting to suspend Bluetooth: Avoid potential use-after-free in hci_error_reset Bluetooth: hci_sync: Check the correct flag before starting a scan Bluetooth: hci_bcm4377: do not mark valid bd_addr as invalid ==================== Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
2 parents 8f5afe4 + 6abf9dd commit 244b96c

File tree

9 files changed

+48
-20
lines changed

9 files changed

+48
-20
lines changed

drivers/bluetooth/btqca.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ static int qca_send_patch_config_cmd(struct hci_dev *hdev)
152152
bt_dev_dbg(hdev, "QCA Patch config");
153153

154154
skb = __hci_cmd_sync_ev(hdev, EDL_PATCH_CMD_OPCODE, sizeof(cmd),
155-
cmd, HCI_EV_VENDOR, HCI_INIT_TIMEOUT);
155+
cmd, 0, HCI_INIT_TIMEOUT);
156156
if (IS_ERR(skb)) {
157157
err = PTR_ERR(skb);
158158
bt_dev_err(hdev, "Sending QCA Patch config failed (%d)", err);

drivers/bluetooth/hci_bcm4377.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1417,7 +1417,7 @@ static int bcm4377_check_bdaddr(struct bcm4377_data *bcm4377)
14171417

14181418
bda = (struct hci_rp_read_bd_addr *)skb->data;
14191419
if (!bcm4377_is_valid_bdaddr(bcm4377, &bda->bdaddr))
1420-
set_bit(HCI_QUIRK_INVALID_BDADDR, &bcm4377->hdev->quirks);
1420+
set_bit(HCI_QUIRK_USE_BDADDR_PROPERTY, &bcm4377->hdev->quirks);
14211421

14221422
kfree_skb(skb);
14231423
return 0;
@@ -2368,7 +2368,6 @@ static int bcm4377_probe(struct pci_dev *pdev, const struct pci_device_id *id)
23682368
hdev->set_bdaddr = bcm4377_hci_set_bdaddr;
23692369
hdev->setup = bcm4377_hci_setup;
23702370

2371-
set_bit(HCI_QUIRK_USE_BDADDR_PROPERTY, &hdev->quirks);
23722371
if (bcm4377->hw->broken_mws_transport_config)
23732372
set_bit(HCI_QUIRK_BROKEN_MWS_TRANSPORT_CONFIG, &hdev->quirks);
23742373
if (bcm4377->hw->broken_ext_scan)

drivers/bluetooth/hci_qca.c

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
*
88
* Copyright (C) 2007 Texas Instruments, Inc.
99
* Copyright (c) 2010, 2012, 2018 The Linux Foundation. All rights reserved.
10+
* Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved.
1011
*
1112
* Acknowledgements:
1213
* This file is based on hci_ll.c, which was...
@@ -1806,13 +1807,12 @@ static int qca_power_on(struct hci_dev *hdev)
18061807

18071808
static void hci_coredump_qca(struct hci_dev *hdev)
18081809
{
1810+
int err;
18091811
static const u8 param[] = { 0x26 };
1810-
struct sk_buff *skb;
18111812

1812-
skb = __hci_cmd_sync(hdev, 0xfc0c, 1, param, HCI_CMD_TIMEOUT);
1813-
if (IS_ERR(skb))
1814-
bt_dev_err(hdev, "%s: trigger crash failed (%ld)", __func__, PTR_ERR(skb));
1815-
kfree_skb(skb);
1813+
err = __hci_cmd_send(hdev, 0xfc0c, 1, param);
1814+
if (err < 0)
1815+
bt_dev_err(hdev, "%s: trigger crash failed (%d)", __func__, err);
18161816
}
18171817

18181818
static int qca_get_data_path_id(struct hci_dev *hdev, __u8 *data_path_id)
@@ -1904,7 +1904,17 @@ static int qca_setup(struct hci_uart *hu)
19041904
case QCA_WCN6750:
19051905
case QCA_WCN6855:
19061906
case QCA_WCN7850:
1907-
set_bit(HCI_QUIRK_USE_BDADDR_PROPERTY, &hdev->quirks);
1907+
1908+
/* Set BDA quirk bit for reading BDA value from fwnode property
1909+
* only if that property exist in DT.
1910+
*/
1911+
if (fwnode_property_present(dev_fwnode(hdev->dev.parent), "local-bd-address")) {
1912+
set_bit(HCI_QUIRK_USE_BDADDR_PROPERTY, &hdev->quirks);
1913+
bt_dev_info(hdev, "setting quirk bit to read BDA from fwnode later");
1914+
} else {
1915+
bt_dev_dbg(hdev, "local-bd-address` is not present in the devicetree so not setting quirk bit for BDA");
1916+
}
1917+
19081918
hci_set_aosp_capable(hdev);
19091919

19101920
ret = qca_read_soc_version(hdev, &ver, soc_type);

net/bluetooth/hci_core.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1049,17 +1049,18 @@ static void hci_error_reset(struct work_struct *work)
10491049
{
10501050
struct hci_dev *hdev = container_of(work, struct hci_dev, error_reset);
10511051

1052+
hci_dev_hold(hdev);
10521053
BT_DBG("%s", hdev->name);
10531054

10541055
if (hdev->hw_error)
10551056
hdev->hw_error(hdev, hdev->hw_error_code);
10561057
else
10571058
bt_dev_err(hdev, "hardware error 0x%2.2x", hdev->hw_error_code);
10581059

1059-
if (hci_dev_do_close(hdev))
1060-
return;
1060+
if (!hci_dev_do_close(hdev))
1061+
hci_dev_do_open(hdev);
10611062

1062-
hci_dev_do_open(hdev);
1063+
hci_dev_put(hdev);
10631064
}
10641065

10651066
void hci_uuids_clear(struct hci_dev *hdev)

net/bluetooth/hci_event.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5329,9 +5329,12 @@ static void hci_io_capa_request_evt(struct hci_dev *hdev, void *data,
53295329
hci_dev_lock(hdev);
53305330

53315331
conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK, &ev->bdaddr);
5332-
if (!conn || !hci_conn_ssp_enabled(conn))
5332+
if (!conn || !hci_dev_test_flag(hdev, HCI_SSP_ENABLED))
53335333
goto unlock;
53345334

5335+
/* Assume remote supports SSP since it has triggered this event */
5336+
set_bit(HCI_CONN_SSP_ENABLED, &conn->flags);
5337+
53355338
hci_conn_hold(conn);
53365339

53375340
if (!hci_dev_test_flag(hdev, HCI_MGMT))
@@ -6794,6 +6797,10 @@ static void hci_le_remote_conn_param_req_evt(struct hci_dev *hdev, void *data,
67946797
return send_conn_param_neg_reply(hdev, handle,
67956798
HCI_ERROR_UNKNOWN_CONN_ID);
67966799

6800+
if (max > hcon->le_conn_max_interval)
6801+
return send_conn_param_neg_reply(hdev, handle,
6802+
HCI_ERROR_INVALID_LL_PARAMS);
6803+
67976804
if (hci_check_conn_params(min, max, latency, timeout))
67986805
return send_conn_param_neg_reply(hdev, handle,
67996806
HCI_ERROR_INVALID_LL_PARAMS);
@@ -7420,10 +7427,10 @@ static void hci_store_wake_reason(struct hci_dev *hdev, u8 event,
74207427
* keep track of the bdaddr of the connection event that woke us up.
74217428
*/
74227429
if (event == HCI_EV_CONN_REQUEST) {
7423-
bacpy(&hdev->wake_addr, &conn_complete->bdaddr);
7430+
bacpy(&hdev->wake_addr, &conn_request->bdaddr);
74247431
hdev->wake_addr_type = BDADDR_BREDR;
74257432
} else if (event == HCI_EV_CONN_COMPLETE) {
7426-
bacpy(&hdev->wake_addr, &conn_request->bdaddr);
7433+
bacpy(&hdev->wake_addr, &conn_complete->bdaddr);
74277434
hdev->wake_addr_type = BDADDR_BREDR;
74287435
} else if (event == HCI_EV_LE_META) {
74297436
struct hci_ev_le_meta *le_ev = (void *)skb->data;

net/bluetooth/hci_sync.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2206,8 +2206,11 @@ static int hci_le_add_accept_list_sync(struct hci_dev *hdev,
22062206

22072207
/* During suspend, only wakeable devices can be in acceptlist */
22082208
if (hdev->suspended &&
2209-
!(params->flags & HCI_CONN_FLAG_REMOTE_WAKEUP))
2209+
!(params->flags & HCI_CONN_FLAG_REMOTE_WAKEUP)) {
2210+
hci_le_del_accept_list_sync(hdev, &params->addr,
2211+
params->addr_type);
22102212
return 0;
2213+
}
22112214

22122215
/* Select filter policy to accept all advertising */
22132216
if (*num_entries >= hdev->le_accept_list_size)
@@ -5559,7 +5562,7 @@ static int hci_inquiry_sync(struct hci_dev *hdev, u8 length)
55595562

55605563
bt_dev_dbg(hdev, "");
55615564

5562-
if (hci_dev_test_flag(hdev, HCI_INQUIRY))
5565+
if (test_bit(HCI_INQUIRY, &hdev->flags))
55635566
return 0;
55645567

55655568
hci_dev_lock(hdev);

net/bluetooth/l2cap_core.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5613,7 +5613,13 @@ static inline int l2cap_conn_param_update_req(struct l2cap_conn *conn,
56135613

56145614
memset(&rsp, 0, sizeof(rsp));
56155615

5616-
err = hci_check_conn_params(min, max, latency, to_multiplier);
5616+
if (max > hcon->le_conn_max_interval) {
5617+
BT_DBG("requested connection interval exceeds current bounds.");
5618+
err = -EINVAL;
5619+
} else {
5620+
err = hci_check_conn_params(min, max, latency, to_multiplier);
5621+
}
5622+
56175623
if (err)
56185624
rsp.result = cpu_to_le16(L2CAP_CONN_PARAM_REJECTED);
56195625
else

net/bluetooth/mgmt.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1045,6 +1045,8 @@ static void rpa_expired(struct work_struct *work)
10451045
hci_cmd_sync_queue(hdev, rpa_expired_sync, NULL, NULL);
10461046
}
10471047

1048+
static int set_discoverable_sync(struct hci_dev *hdev, void *data);
1049+
10481050
static void discov_off(struct work_struct *work)
10491051
{
10501052
struct hci_dev *hdev = container_of(work, struct hci_dev,
@@ -1063,7 +1065,7 @@ static void discov_off(struct work_struct *work)
10631065
hci_dev_clear_flag(hdev, HCI_DISCOVERABLE);
10641066
hdev->discov_timeout = 0;
10651067

1066-
hci_update_discoverable(hdev);
1068+
hci_cmd_sync_queue(hdev, set_discoverable_sync, NULL, NULL);
10671069

10681070
mgmt_new_settings(hdev);
10691071

net/bluetooth/rfcomm/core.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1941,7 +1941,7 @@ static struct rfcomm_session *rfcomm_process_rx(struct rfcomm_session *s)
19411941
/* Get data directly from socket receive queue without copying it. */
19421942
while ((skb = skb_dequeue(&sk->sk_receive_queue))) {
19431943
skb_orphan(skb);
1944-
if (!skb_linearize(skb)) {
1944+
if (!skb_linearize(skb) && sk->sk_state != BT_CLOSED) {
19451945
s = rfcomm_recv_frame(s, skb);
19461946
if (!s)
19471947
break;

0 commit comments

Comments
 (0)