Commit e3492dc3 authored by David Herrmann's avatar David Herrmann Committed by Gustavo Padovan

Bluetooth: hidp: test "terminate" before sleeping

The "terminate" flag is guaranteed to be set before the session terminates
and the handlers are woken up. Hence, we need to add it to the
sleep-condition.

Note that testing the flags is not enough as nothing prevents us from
setting the flags again after the session-handler terminated.
Signed-off-by: default avatarDavid Herrmann <dh.herrmann@gmail.com>
Acked-by: default avatarMarcel Holtmann <marcel@holtmann.org>
Signed-off-by: default avatarGustavo Padovan <gustavo.padovan@collabora.co.uk>
parent dcc07647
...@@ -330,11 +330,13 @@ static int hidp_get_raw_report(struct hid_device *hid, ...@@ -330,11 +330,13 @@ static int hidp_get_raw_report(struct hid_device *hid,
/* Wait for the return of the report. The returned report /* Wait for the return of the report. The returned report
gets put in session->report_return. */ gets put in session->report_return. */
while (test_bit(HIDP_WAITING_FOR_RETURN, &session->flags)) { while (test_bit(HIDP_WAITING_FOR_RETURN, &session->flags) &&
!atomic_read(&session->terminate)) {
int res; int res;
res = wait_event_interruptible_timeout(session->report_queue, res = wait_event_interruptible_timeout(session->report_queue,
!test_bit(HIDP_WAITING_FOR_RETURN, &session->flags), !test_bit(HIDP_WAITING_FOR_RETURN, &session->flags)
|| atomic_read(&session->terminate),
5*HZ); 5*HZ);
if (res == 0) { if (res == 0) {
/* timeout */ /* timeout */
...@@ -399,11 +401,13 @@ static int hidp_output_raw_report(struct hid_device *hid, unsigned char *data, s ...@@ -399,11 +401,13 @@ static int hidp_output_raw_report(struct hid_device *hid, unsigned char *data, s
goto err; goto err;
/* Wait for the ACK from the device. */ /* Wait for the ACK from the device. */
while (test_bit(HIDP_WAITING_FOR_SEND_ACK, &session->flags)) { while (test_bit(HIDP_WAITING_FOR_SEND_ACK, &session->flags) &&
!atomic_read(&session->terminate)) {
int res; int res;
res = wait_event_interruptible_timeout(session->report_queue, res = wait_event_interruptible_timeout(session->report_queue,
!test_bit(HIDP_WAITING_FOR_SEND_ACK, &session->flags), !test_bit(HIDP_WAITING_FOR_SEND_ACK, &session->flags)
|| atomic_read(&session->terminate),
10*HZ); 10*HZ);
if (res == 0) { if (res == 0) {
/* timeout */ /* timeout */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment