Skip to content

Commit

Permalink
Bluetooth: ISO: Fix not using the correct QoS
Browse files Browse the repository at this point in the history
This fixes using wrong QoS settings when attempting to send frames while
acting as peripheral since the QoS settings in use are stored in
hconn->iso_qos not in sk->qos, this is actually properly handled on
getsockopt(BT_ISO_QOS) but not on iso_send_frame.

Fixes: ccf74f2 ("Bluetooth: Add BTPROTO_ISO socket type")
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
  • Loading branch information
Luiz Augusto von Dentz committed Aug 9, 2022
1 parent 3f2893d commit 1d1ab5d
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions net/bluetooth/iso.c
Original file line number Diff line number Diff line change
Expand Up @@ -373,15 +373,24 @@ static int iso_connect_cis(struct sock *sk)
return err;
}

static struct bt_iso_qos *iso_sock_get_qos(struct sock *sk)
{
if (sk->sk_state == BT_CONNECTED || sk->sk_state == BT_CONNECT2)
return &iso_pi(sk)->conn->hcon->iso_qos;

return &iso_pi(sk)->qos;
}

static int iso_send_frame(struct sock *sk, struct sk_buff *skb)
{
struct iso_conn *conn = iso_pi(sk)->conn;
struct bt_iso_qos *qos = iso_sock_get_qos(sk);
struct hci_iso_data_hdr *hdr;
int len = 0;

BT_DBG("sk %p len %d", sk, skb->len);

if (skb->len > iso_pi(sk)->qos.out.sdu)
if (skb->len > qos->out.sdu)
return -EMSGSIZE;

len = skb->len;
Expand Down Expand Up @@ -1263,10 +1272,7 @@ static int iso_sock_getsockopt(struct socket *sock, int level, int optname,
break;

case BT_ISO_QOS:
if (sk->sk_state == BT_CONNECTED || sk->sk_state == BT_CONNECT2)
qos = &iso_pi(sk)->conn->hcon->iso_qos;
else
qos = &iso_pi(sk)->qos;
qos = iso_sock_get_qos(sk);

len = min_t(unsigned int, len, sizeof(*qos));
if (copy_to_user(optval, qos, len))
Expand Down

0 comments on commit 1d1ab5d

Please sign in to comment.