Skip to content

Commit 755b82a

Browse files
holtmannjhedberg
authored andcommitted
Bluetooth: Access HIDP session addresses through L2CAP channel
The L2CAP socket structure does not contain the address information anymore. They need to be accessed through the L2CAP channel. Signed-off-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
1 parent 88f1fd2 commit 755b82a

1 file changed

Lines changed: 12 additions & 6 deletions

File tree

‎net/bluetooth/hidp/core.c‎

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -767,10 +767,10 @@ static int hidp_setup_hid(struct hidp_session *session,
767767
strncpy(hid->name, req->name, sizeof(req->name) - 1);
768768

769769
snprintf(hid->phys, sizeof(hid->phys), "%pMR",
770-
&bt_sk(session->ctrl_sock->sk)->src);
770+
&l2cap_pi(session->ctrl_sock->sk)->chan->src);
771771

772772
snprintf(hid->uniq, sizeof(hid->uniq), "%pMR",
773-
&bt_sk(session->ctrl_sock->sk)->dst);
773+
&l2cap_pi(session->ctrl_sock->sk)->chan->dst);
774774

775775
hid->dev.parent = &session->conn->hcon->dev;
776776
hid->ll_driver = &hidp_hid_driver;
@@ -1283,23 +1283,29 @@ static int hidp_session_thread(void *arg)
12831283
static int hidp_verify_sockets(struct socket *ctrl_sock,
12841284
struct socket *intr_sock)
12851285
{
1286+
struct l2cap_chan *ctrl_chan, *intr_chan;
12861287
struct bt_sock *ctrl, *intr;
12871288
struct hidp_session *session;
12881289

12891290
if (!l2cap_is_socket(ctrl_sock) || !l2cap_is_socket(intr_sock))
12901291
return -EINVAL;
12911292

1293+
ctrl_chan = l2cap_pi(ctrl_sock->sk)->chan;
1294+
intr_chan = l2cap_pi(intr_sock->sk)->chan;
1295+
1296+
if (bacmp(&ctrl_chan->src, &intr_chan->src) ||
1297+
bacmp(&ctrl_chan->dst, &intr_chan->dst))
1298+
return -ENOTUNIQ;
1299+
12921300
ctrl = bt_sk(ctrl_sock->sk);
12931301
intr = bt_sk(intr_sock->sk);
12941302

1295-
if (bacmp(&ctrl->src, &intr->src) || bacmp(&ctrl->dst, &intr->dst))
1296-
return -ENOTUNIQ;
12971303
if (ctrl->sk.sk_state != BT_CONNECTED ||
12981304
intr->sk.sk_state != BT_CONNECTED)
12991305
return -EBADFD;
13001306

13011307
/* early session check, we check again during session registration */
1302-
session = hidp_session_find(&ctrl->dst);
1308+
session = hidp_session_find(&ctrl_chan->dst);
13031309
if (session) {
13041310
hidp_session_put(session);
13051311
return -EEXIST;
@@ -1332,7 +1338,7 @@ int hidp_connection_add(struct hidp_connadd_req *req,
13321338
if (!conn)
13331339
return -EBADFD;
13341340

1335-
ret = hidp_session_new(&session, &bt_sk(ctrl_sock->sk)->dst, ctrl_sock,
1341+
ret = hidp_session_new(&session, &chan->dst, ctrl_sock,
13361342
intr_sock, req, conn);
13371343
if (ret)
13381344
goto out_conn;

0 commit comments

Comments
 (0)