Skip to content

Commit

Permalink
Bluetooth: SCO: Fix sco_send_frame returning skb->len
Browse files Browse the repository at this point in the history
The skb in modified by hci_send_sco which pushes SCO headers thus
changing skb->len causing sco_sock_sendmsg to fail.

Fixes: 0771cbb ("Bluetooth: SCO: Replace use of memcpy_from_msg with bt_skb_sendmsg")
Tested-by: Tedd Ho-Jeong An <tedd.an@intel.com>
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
  • Loading branch information
Luiz Augusto von Dentz authored and Marcel Holtmann committed Sep 21, 2021
1 parent 266191a commit 037ce00
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions net/bluetooth/sco.c
Original file line number Diff line number Diff line change
Expand Up @@ -284,16 +284,17 @@ static int sco_connect(struct hci_dev *hdev, struct sock *sk)
static int sco_send_frame(struct sock *sk, struct sk_buff *skb)
{
struct sco_conn *conn = sco_pi(sk)->conn;
int len = skb->len;

/* Check outgoing MTU */
if (skb->len > conn->mtu)
if (len > conn->mtu)
return -EINVAL;

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

hci_send_sco(conn->hcon, skb);

return skb->len;
return len;
}

static void sco_recv_frame(struct sco_conn *conn, struct sk_buff *skb)
Expand Down Expand Up @@ -744,7 +745,8 @@ static int sco_sock_sendmsg(struct socket *sock, struct msghdr *msg,
err = -ENOTCONN;

release_sock(sk);
if (err)

if (err < 0)
kfree_skb(skb);
return err;
}
Expand Down

0 comments on commit 037ce00

Please sign in to comment.