Skip to content

Commit cc11092

Browse files
vcgomesGustavo Padovan
authored andcommitted
Bluetooth: Change signature of smp_conn_security()
To make it clear that it may be called from contexts that may not have any knowledge of L2CAP, we change the connection parameter, to receive a hci_conn. This also makes it clear that it is checking the security of the link. Signed-off-by: Vinicius Costa Gomes <vinicius.gomes@openbossa.org> Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
1 parent 1fa6535 commit cc11092

4 files changed

Lines changed: 10 additions & 9 deletions

File tree

‎include/net/bluetooth/smp.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ struct smp_chan {
136136
};
137137

138138
/* SMP Commands */
139-
int smp_conn_security(struct l2cap_conn *conn, __u8 sec_level);
139+
int smp_conn_security(struct hci_conn *hcon, __u8 sec_level);
140140
int smp_sig_channel(struct l2cap_conn *conn, struct sk_buff *skb);
141141
int smp_distribute_keys(struct l2cap_conn *conn, __u8 force);
142142
int smp_user_confirm_reply(struct hci_conn *conn, u16 mgmt_op, __le32 passkey);

‎net/bluetooth/l2cap_core.c‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1199,14 +1199,15 @@ static void l2cap_le_conn_ready(struct l2cap_conn *conn)
11991199
static void l2cap_conn_ready(struct l2cap_conn *conn)
12001200
{
12011201
struct l2cap_chan *chan;
1202+
struct hci_conn *hcon = conn->hcon;
12021203

12031204
BT_DBG("conn %p", conn);
12041205

1205-
if (!conn->hcon->out && conn->hcon->type == LE_LINK)
1206+
if (!hcon->out && hcon->type == LE_LINK)
12061207
l2cap_le_conn_ready(conn);
12071208

1208-
if (conn->hcon->out && conn->hcon->type == LE_LINK)
1209-
smp_conn_security(conn, conn->hcon->pending_sec_level);
1209+
if (hcon->out && hcon->type == LE_LINK)
1210+
smp_conn_security(hcon, hcon->pending_sec_level);
12101211

12111212
mutex_lock(&conn->chan_lock);
12121213

@@ -1219,8 +1220,8 @@ static void l2cap_conn_ready(struct l2cap_conn *conn)
12191220
continue;
12201221
}
12211222

1222-
if (conn->hcon->type == LE_LINK) {
1223-
if (smp_conn_security(conn, chan->sec_level))
1223+
if (hcon->type == LE_LINK) {
1224+
if (smp_conn_security(hcon, chan->sec_level))
12241225
l2cap_chan_ready(chan);
12251226

12261227
} else if (chan->chan_type != L2CAP_CHAN_CONN_ORIENTED) {

‎net/bluetooth/l2cap_sock.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -615,7 +615,7 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname, ch
615615
break;
616616
}
617617

618-
if (smp_conn_security(conn, sec.level))
618+
if (smp_conn_security(conn->hcon, sec.level))
619619
break;
620620
sk->sk_state = BT_CONFIG;
621621
chan->state = BT_CONFIG;

‎net/bluetooth/smp.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -760,9 +760,9 @@ static u8 smp_cmd_security_req(struct l2cap_conn *conn, struct sk_buff *skb)
760760
return 0;
761761
}
762762

763-
int smp_conn_security(struct l2cap_conn *conn, __u8 sec_level)
763+
int smp_conn_security(struct hci_conn *hcon, __u8 sec_level)
764764
{
765-
struct hci_conn *hcon = conn->hcon;
765+
struct l2cap_conn *conn = hcon->l2cap_data;
766766
struct smp_chan *smp = conn->smp_chan;
767767
__u8 authreq;
768768

0 commit comments

Comments
 (0)