tests/bluetooth/tester: Allocate L2CAP channel only when needed

This fix leaking channels when autorization or key size are tested.

Signed-off-by: Szymon Janc <szymon.janc@codecoup.pl>
This commit is contained in:
Szymon Janc 2022-02-01 16:48:01 +01:00 committed by Carles Cufí
parent 4b40915004
commit c631469539

View file

@ -441,11 +441,6 @@ static int accept(struct bt_conn *conn, struct bt_l2cap_chan **l2cap_chan)
{
struct channel *chan;
chan = get_free_channel();
if (!chan) {
return -ENOMEM;
}
if (bt_conn_enc_key_size(conn) < req_keysize) {
return -EPERM;
}
@ -454,6 +449,11 @@ static int accept(struct bt_conn *conn, struct bt_l2cap_chan **l2cap_chan)
return -EACCES;
}
chan = get_free_channel();
if (!chan) {
return -ENOMEM;
}
chan->le.chan.ops = &l2cap_ops;
chan->le.rx.mtu = DATA_MTU_INITIAL;