diff options
author | Johan Hedberg <johan.hedberg@intel.com> | 2013-10-14 18:17:53 (GMT) |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2013-10-14 18:26:21 (GMT) |
commit | 1f209383f2be94e15e179da3a4cbcfeabcc2efc2 (patch) | |
tree | da1624cca46f1ffe5e7821258673d8b333fa7f8e | |
parent | 80c1a2e76dbb36588facb265ab364b1302f7ef8c (diff) | |
download | linux-fsl-qoriq-1f209383f2be94e15e179da3a4cbcfeabcc2efc2.tar.xz |
Bluetooth: Check that bind() bdaddr type matches connect()
If a socket was bound to an address type other than BR/EDR (such as LE)
we should reject trying to connect it to a BR/EDR address. The same
applies for binding to BR/EDR and trying to connect to non-BR/EDR.
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
-rw-r--r-- | net/bluetooth/l2cap_sock.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c index 3f21207..5ffd75e 100644 --- a/net/bluetooth/l2cap_sock.c +++ b/net/bluetooth/l2cap_sock.c @@ -150,6 +150,12 @@ static int l2cap_sock_connect(struct socket *sock, struct sockaddr *addr, if (!bdaddr_type_is_valid(la.l2_bdaddr_type)) return -EINVAL; + if (chan->src_type == BDADDR_BREDR && la.l2_bdaddr_type != BDADDR_BREDR) + return -EINVAL; + + if (chan->src_type != BDADDR_BREDR && la.l2_bdaddr_type == BDADDR_BREDR) + return -EINVAL; + err = l2cap_chan_connect(chan, la.l2_psm, __le16_to_cpu(la.l2_cid), &la.l2_bdaddr, la.l2_bdaddr_type); if (err) |