Skip to content

Commit ec8dab3

Browse files
committed
[Bluetooth] Signal user-space for HIDP and BNEP socket errors
When using the HIDP or BNEP kernel support, the user-space needs to know if the connection has been terminated for some reasons. Wake up the application if that happens. Otherwise kernel and user-space are no longer on the same page and weird behaviors can happen. Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
1 parent a0c22f2 commit ec8dab3

2 files changed

Lines changed: 15 additions & 0 deletions

File tree

‎net/bluetooth/bnep/core.c‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -507,6 +507,11 @@ static int bnep_session(void *arg)
507507
/* Delete network device */
508508
unregister_netdev(dev);
509509

510+
/* Wakeup user-space polling for socket errors */
511+
s->sock->sk->sk_err = EUNATCH;
512+
513+
wake_up_interruptible(s->sock->sk->sk_sleep);
514+
510515
/* Release the socket */
511516
fput(s->sock->file);
512517

‎net/bluetooth/hidp/core.c‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -581,6 +581,12 @@ static int hidp_session(void *arg)
581581
hid_free_device(session->hid);
582582
}
583583

584+
/* Wakeup user-space polling for socket errors */
585+
session->intr_sock->sk->sk_err = EUNATCH;
586+
session->ctrl_sock->sk->sk_err = EUNATCH;
587+
588+
hidp_schedule(session);
589+
584590
fput(session->intr_sock->file);
585591

586592
wait_event_timeout(*(ctrl_sk->sk_sleep),
@@ -879,6 +885,10 @@ int hidp_del_connection(struct hidp_conndel_req *req)
879885
skb_queue_purge(&session->ctrl_transmit);
880886
skb_queue_purge(&session->intr_transmit);
881887

888+
/* Wakeup user-space polling for socket errors */
889+
session->intr_sock->sk->sk_err = EUNATCH;
890+
session->ctrl_sock->sk->sk_err = EUNATCH;
891+
882892
/* Kill session thread */
883893
atomic_inc(&session->terminate);
884894
hidp_schedule(session);

0 commit comments

Comments
 (0)