summaryrefslogtreecommitdiff
path: root/net/bluetooth/l2cap_core.c
diff options
context:
space:
mode:
authorGustavo Padovan <gustavo.padovan@collabora.co.uk>2012-05-27 22:27:58 -0300
committerJohan Hedberg <johan.hedberg@intel.com>2012-06-05 06:34:11 +0300
commit2dfa1003ccd19b435de0be00f6afb7ccdffd7596 (patch)
tree3d09f8d4f15569d4be0a5ef607fe70742a378953 /net/bluetooth/l2cap_core.c
parent538266929eb7165f92b91eb0f403120fe759e742 (diff)
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: Gustavo Padovan <gustavo.padovan@collabora.co.uk> Acked-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Diffstat (limited to 'net/bluetooth/l2cap_core.c')
-rw-r--r--net/bluetooth/l2cap_core.c13
1 files changed, 4 insertions, 9 deletions
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index d64c836f2bcf..6f30d1da89a0 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -3343,21 +3343,16 @@ static inline int l2cap_connect_req(struct l2cap_conn *conn, struct l2cap_cmd_hd
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);
if (!chan)
goto response;
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);
bacpy(&bt_sk(sk)->src, conn->src);