Commit d5f2d2be68876f65dd051b978a7b66265fde9ffd

Authored by Marcel Holtmann
1 parent 96a3183322

Bluetooth: Fix poll() misbehavior when using BT_DEFER_SETUP

When BT_DEFER_SETUP has been enabled on a Bluetooth socket it keeps
signaling POLLIN all the time. This is a wrong behavior. The POLLIN
should only be signaled if the client socket is in BT_CONNECT2 state
and the parent has been BT_DEFER_SETUP enabled.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>

Showing 1 changed file with 3 additions and 4 deletions Side-by-side Diff

net/bluetooth/af_bluetooth.c
... ... @@ -270,12 +270,11 @@
270 270 struct list_head *p, *n;
271 271 struct sock *sk;
272 272  
273   - if (bt_sk(parent)->defer_setup)
274   - return POLLIN | POLLRDNORM;
275   -
276 273 list_for_each_safe(p, n, &bt_sk(parent)->accept_q) {
277 274 sk = (struct sock *) list_entry(p, struct bt_sock, accept_q);
278   - if (sk->sk_state == BT_CONNECTED)
  275 + if (sk->sk_state == BT_CONNECTED ||
  276 + (bt_sk(parent)->defer_setup &&
  277 + sk->sk_state == BT_CONNECT2))
279 278 return POLLIN | POLLRDNORM;
280 279 }
281 280