Skip to content

Commit f6b2f57

Browse files
committed
Merge tag 'for-net-2024-06-10' of git://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth
Luiz Augusto von Dentz says: ==================== bluetooth pull request for net: - hci_sync: fix not using correct handle - L2CAP: fix rejecting L2CAP_CONN_PARAM_UPDATE_REQ - L2CAP: fix connection setup in l2cap_connect * tag 'for-net-2024-06-10' of git://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth: Bluetooth: fix connection setup in l2cap_connect Bluetooth: L2CAP: Fix rejecting L2CAP_CONN_PARAM_UPDATE_REQ Bluetooth: hci_sync: Fix not using correct handle ==================== Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
2 parents 144ba85 + c695439 commit f6b2f57

File tree

3 files changed

+36
-14
lines changed

3 files changed

+36
-14
lines changed

include/net/bluetooth/hci_core.h

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2113,18 +2113,46 @@ static inline int hci_check_conn_params(u16 min, u16 max, u16 latency,
21132113
{
21142114
u16 max_latency;
21152115

2116-
if (min > max || min < 6 || max > 3200)
2116+
if (min > max) {
2117+
BT_WARN("min %d > max %d", min, max);
21172118
return -EINVAL;
2119+
}
2120+
2121+
if (min < 6) {
2122+
BT_WARN("min %d < 6", min);
2123+
return -EINVAL;
2124+
}
2125+
2126+
if (max > 3200) {
2127+
BT_WARN("max %d > 3200", max);
2128+
return -EINVAL;
2129+
}
2130+
2131+
if (to_multiplier < 10) {
2132+
BT_WARN("to_multiplier %d < 10", to_multiplier);
2133+
return -EINVAL;
2134+
}
21182135

2119-
if (to_multiplier < 10 || to_multiplier > 3200)
2136+
if (to_multiplier > 3200) {
2137+
BT_WARN("to_multiplier %d > 3200", to_multiplier);
21202138
return -EINVAL;
2139+
}
21212140

2122-
if (max >= to_multiplier * 8)
2141+
if (max >= to_multiplier * 8) {
2142+
BT_WARN("max %d >= to_multiplier %d * 8", max, to_multiplier);
21232143
return -EINVAL;
2144+
}
21242145

21252146
max_latency = (to_multiplier * 4 / max) - 1;
2126-
if (latency > 499 || latency > max_latency)
2147+
if (latency > 499) {
2148+
BT_WARN("latency %d > 499", latency);
21272149
return -EINVAL;
2150+
}
2151+
2152+
if (latency > max_latency) {
2153+
BT_WARN("latency %d > max_latency %d", latency, max_latency);
2154+
return -EINVAL;
2155+
}
21282156

21292157
return 0;
21302158
}

net/bluetooth/hci_sync.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1194,7 +1194,7 @@ int hci_setup_ext_adv_instance_sync(struct hci_dev *hdev, u8 instance)
11941194

11951195
cp.own_addr_type = own_addr_type;
11961196
cp.channel_map = hdev->le_adv_channel_map;
1197-
cp.handle = instance;
1197+
cp.handle = adv ? adv->handle : instance;
11981198

11991199
if (flags & MGMT_ADV_FLAG_SEC_2M) {
12001200
cp.primary_phy = HCI_ADV_PHY_1M;

net/bluetooth/l2cap_core.c

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4011,8 +4011,8 @@ static void l2cap_connect(struct l2cap_conn *conn, struct l2cap_cmd_hdr *cmd,
40114011
status = L2CAP_CS_AUTHOR_PEND;
40124012
chan->ops->defer(chan);
40134013
} else {
4014-
l2cap_state_change(chan, BT_CONNECT2);
4015-
result = L2CAP_CR_PEND;
4014+
l2cap_state_change(chan, BT_CONFIG);
4015+
result = L2CAP_CR_SUCCESS;
40164016
status = L2CAP_CS_NO_INFO;
40174017
}
40184018
} else {
@@ -4647,13 +4647,7 @@ static inline int l2cap_conn_param_update_req(struct l2cap_conn *conn,
46474647

46484648
memset(&rsp, 0, sizeof(rsp));
46494649

4650-
if (max > hcon->le_conn_max_interval) {
4651-
BT_DBG("requested connection interval exceeds current bounds.");
4652-
err = -EINVAL;
4653-
} else {
4654-
err = hci_check_conn_params(min, max, latency, to_multiplier);
4655-
}
4656-
4650+
err = hci_check_conn_params(min, max, latency, to_multiplier);
46574651
if (err)
46584652
rsp.result = cpu_to_le16(L2CAP_CONN_PARAM_REJECTED);
46594653
else

0 commit comments

Comments
 (0)