Commit 2dfa1003 authored by Gustavo Padovan's avatar Gustavo Padovan Committed by Johan Hedberg

Bluetooth: check for already existent channel before create new one

Move this check to before the channel time creation simplifies the code
and avoid memory allocation if the channel already exist.
Signed-off-by: default avatarGustavo Padovan <gustavo.padovan@collabora.co.uk>
Acked-by: default avatarAndrei Emeltchenko <andrei.emeltchenko@intel.com>
Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
parent 53826692
...@@ -3343,21 +3343,16 @@ static inline int l2cap_connect_req(struct l2cap_conn *conn, struct l2cap_cmd_hd ...@@ -3343,21 +3343,16 @@ static inline int l2cap_connect_req(struct l2cap_conn *conn, struct l2cap_cmd_hd
result = L2CAP_CR_NO_MEM; result = L2CAP_CR_NO_MEM;
/* Check if we already have channel with that dcid */
if (__l2cap_get_chan_by_dcid(conn, scid))
goto response;
chan = pchan->ops->new_connection(pchan); chan = pchan->ops->new_connection(pchan);
if (!chan) if (!chan)
goto response; goto response;
sk = chan->sk; sk = chan->sk;
/* Check if we already have channel with that dcid */
if (__l2cap_get_chan_by_dcid(conn, scid)) {
if (chan->ops->teardown)
chan->ops->teardown(chan, 0);
chan->ops->close(chan);
goto response;
}
hci_conn_hold(conn->hcon); hci_conn_hold(conn->hcon);
bacpy(&bt_sk(sk)->src, conn->src); bacpy(&bt_sk(sk)->src, conn->src);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment