Skip to content

Commit b9f9dba

Browse files
Dan Carpenterholtmann
authored andcommitted
Bluetooth: hci_sock: fix endian bug in hci_sock_setsockopt()
This copies a u16 into the high bits of an int, which works on a big endian system but not on a little endian system. Fixes: 09572fc ("Bluetooth: hci_sock: Add support for BT_{SND,RCV}BUF") Signed-off-by: Dan Carpenter <[email protected]> Signed-off-by: Marcel Holtmann <[email protected]>
1 parent 2b70d4f commit b9f9dba

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

net/bluetooth/hci_sock.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1911,7 +1911,8 @@ static int hci_sock_setsockopt(struct socket *sock, int level, int optname,
19111911
sockptr_t optval, unsigned int len)
19121912
{
19131913
struct sock *sk = sock->sk;
1914-
int err = 0, opt = 0;
1914+
int err = 0;
1915+
u16 opt;
19151916

19161917
BT_DBG("sk %p, opt %d", sk, optname);
19171918

@@ -1937,7 +1938,7 @@ static int hci_sock_setsockopt(struct socket *sock, int level, int optname,
19371938
goto done;
19381939
}
19391940

1940-
if (copy_from_sockptr(&opt, optval, sizeof(u16))) {
1941+
if (copy_from_sockptr(&opt, optval, sizeof(opt))) {
19411942
err = -EFAULT;
19421943
break;
19431944
}

0 commit comments

Comments
 (0)