Skip to content

Commit b86b0b1

Browse files
Vudentzholtmann
authored andcommitted
Bluetooth: L2CAP: Fix handling LE modes by L2CAP_OPTIONS
L2CAP_OPTIONS shall only be used with BR/EDR modes. Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
1 parent 139dfad commit b86b0b1

File tree

1 file changed

+21
-4
lines changed

1 file changed

+21
-4
lines changed

net/bluetooth/l2cap_sock.c

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,20 @@ static int l2cap_sock_getsockopt_old(struct socket *sock, int optname,
424424
break;
425425
}
426426

427+
/* Only BR/EDR modes are supported here */
428+
switch (chan->mode) {
429+
case L2CAP_MODE_BASIC:
430+
case L2CAP_MODE_ERTM:
431+
case L2CAP_MODE_STREAMING:
432+
break;
433+
default:
434+
err = -EINVAL;
435+
break;
436+
}
437+
438+
if (err < 0)
439+
break;
440+
427441
memset(&opts, 0, sizeof(opts));
428442
opts.imtu = chan->imtu;
429443
opts.omtu = chan->omtu;
@@ -698,10 +712,8 @@ static int l2cap_sock_setsockopt_old(struct socket *sock, int optname,
698712
break;
699713
}
700714

701-
chan->mode = opts.mode;
702-
switch (chan->mode) {
703-
case L2CAP_MODE_LE_FLOWCTL:
704-
break;
715+
/* Only BR/EDR modes are supported here */
716+
switch (opts.mode) {
705717
case L2CAP_MODE_BASIC:
706718
clear_bit(CONF_STATE2_DEVICE, &chan->conf_state);
707719
break;
@@ -715,6 +727,11 @@ static int l2cap_sock_setsockopt_old(struct socket *sock, int optname,
715727
break;
716728
}
717729

730+
if (err < 0)
731+
break;
732+
733+
chan->mode = opts.mode;
734+
718735
BT_DBG("mode 0x%2.2x", chan->mode);
719736

720737
chan->imtu = opts.imtu;

0 commit comments

Comments
 (0)