Bluetooth: fix incorrect nonblock bitmask in bt_sock_wait_ready()
authorGavin Li <gavin@matician.com>
Mon, 14 Mar 2022 22:42:52 +0000 (15:42 -0700)
committerMarcel Holtmann <marcel@holtmann.org>
Fri, 18 Mar 2022 16:12:08 +0000 (17:12 +0100)
Callers pass msg->msg_flags as flags, which contains MSG_DONTWAIT
instead of O_NONBLOCK.

Signed-off-by: Gavin Li <gavin@matician.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
include/net/bluetooth/bluetooth.h
net/bluetooth/af_bluetooth.c

index 2aa5e95808a5a8ae860215ed29c95c8d76b9311f..6b48d9e2aab9dc6e66f48003b9e62ab811ecfab9 100644 (file)
@@ -345,7 +345,7 @@ int  bt_sock_stream_recvmsg(struct socket *sock, struct msghdr *msg,
 __poll_t bt_sock_poll(struct file *file, struct socket *sock, poll_table *wait);
 int  bt_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg);
 int  bt_sock_wait_state(struct sock *sk, int state, unsigned long timeo);
-int  bt_sock_wait_ready(struct sock *sk, unsigned long flags);
+int  bt_sock_wait_ready(struct sock *sk, unsigned int msg_flags);
 
 void bt_accept_enqueue(struct sock *parent, struct sock *sk, bool bh);
 void bt_accept_unlink(struct sock *sk);
index ee319779781e64657d6e7c3090086c94a5ec6cb7..a0cb2e3da8d4c05b5c0198da2dce3c270109ce26 100644 (file)
@@ -568,7 +568,7 @@ int bt_sock_wait_state(struct sock *sk, int state, unsigned long timeo)
 EXPORT_SYMBOL(bt_sock_wait_state);
 
 /* This function expects the sk lock to be held when called */
-int bt_sock_wait_ready(struct sock *sk, unsigned long flags)
+int bt_sock_wait_ready(struct sock *sk, unsigned int msg_flags)
 {
        DECLARE_WAITQUEUE(wait, current);
        unsigned long timeo;
@@ -576,7 +576,7 @@ int bt_sock_wait_ready(struct sock *sk, unsigned long flags)
 
        BT_DBG("sk %p", sk);
 
-       timeo = sock_sndtimeo(sk, flags & O_NONBLOCK);
+       timeo = sock_sndtimeo(sk, !!(msg_flags & MSG_DONTWAIT));
 
        add_wait_queue(sk_sleep(sk), &wait);
        set_current_state(TASK_INTERRUPTIBLE);