Skip to content

Commit 92594a5

Browse files
Johan Hedbergholtmann
authored andcommitted
Bluetooth: L2CAP: Fix auto-allocating LE PSM values
The LE dynamic PSM range is different from BR/EDR (0x0080 - 0x00ff) and doesn't have requirements relating to parity, so separate checks are needed. Signed-off-by: Johan Hedberg <johan.hedberg@intel.com> Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
1 parent 114f9f1 commit 92594a5

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

net/bluetooth/l2cap_core.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,10 +197,20 @@ int l2cap_add_psm(struct l2cap_chan *chan, bdaddr_t *src, __le16 psm)
197197
chan->sport = psm;
198198
err = 0;
199199
} else {
200-
u16 p;
200+
u16 p, start, end, incr;
201+
202+
if (chan->src_type == BDADDR_BREDR) {
203+
start = L2CAP_PSM_DYN_START;
204+
end = L2CAP_PSM_AUTO_END;
205+
incr = 2;
206+
} else {
207+
start = L2CAP_PSM_LE_DYN_START;
208+
end = L2CAP_PSM_LE_DYN_END;
209+
incr = 1;
210+
}
201211

202212
err = -EINVAL;
203-
for (p = 0x1001; p < 0x1100; p += 2)
213+
for (p = start; p <= end; p += incr)
204214
if (!__l2cap_global_chan_by_addr(cpu_to_le16(p), src)) {
205215
chan->psm = cpu_to_le16(p);
206216
chan->sport = cpu_to_le16(p);

0 commit comments

Comments
 (0)