diff options
author | David Herrmann <dh.herrmann@gmail.com> | 2013-04-06 14:28:41 -0400 |
---|---|---|
committer | Gustavo Padovan <gustavo.padovan@collabora.co.uk> | 2013-04-17 01:47:55 -0400 |
commit | e3492dc3760ceb981a0bb9992c249ba151b6f61d (patch) | |
tree | c7e2fa6b5fb9a3715fb1d0a0b56bca85054ed302 | |
parent | dcc07647f17836ecf9f4c54e44624b048ab8c297 (diff) |
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: David Herrmann <dh.herrmann@gmail.com>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
-rw-r--r-- | net/bluetooth/hidp/core.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/net/bluetooth/hidp/core.c b/net/bluetooth/hidp/core.c index 22e9ab1403a0..e01a9246c14d 100644 --- a/net/bluetooth/hidp/core.c +++ b/net/bluetooth/hidp/core.c | |||
@@ -330,11 +330,13 @@ static int hidp_get_raw_report(struct hid_device *hid, | |||
330 | 330 | ||
331 | /* Wait for the return of the report. The returned report | 331 | /* Wait for the return of the report. The returned report |
332 | gets put in session->report_return. */ | 332 | gets put in session->report_return. */ |
333 | while (test_bit(HIDP_WAITING_FOR_RETURN, &session->flags)) { | 333 | while (test_bit(HIDP_WAITING_FOR_RETURN, &session->flags) && |
334 | !atomic_read(&session->terminate)) { | ||
334 | int res; | 335 | int res; |
335 | 336 | ||
336 | res = wait_event_interruptible_timeout(session->report_queue, | 337 | res = wait_event_interruptible_timeout(session->report_queue, |
337 | !test_bit(HIDP_WAITING_FOR_RETURN, &session->flags), | 338 | !test_bit(HIDP_WAITING_FOR_RETURN, &session->flags) |
339 | || atomic_read(&session->terminate), | ||
338 | 5*HZ); | 340 | 5*HZ); |
339 | if (res == 0) { | 341 | if (res == 0) { |
340 | /* timeout */ | 342 | /* timeout */ |
@@ -399,11 +401,13 @@ static int hidp_output_raw_report(struct hid_device *hid, unsigned char *data, s | |||
399 | goto err; | 401 | goto err; |
400 | 402 | ||
401 | /* Wait for the ACK from the device. */ | 403 | /* Wait for the ACK from the device. */ |
402 | while (test_bit(HIDP_WAITING_FOR_SEND_ACK, &session->flags)) { | 404 | while (test_bit(HIDP_WAITING_FOR_SEND_ACK, &session->flags) && |
405 | !atomic_read(&session->terminate)) { | ||
403 | int res; | 406 | int res; |
404 | 407 | ||
405 | res = wait_event_interruptible_timeout(session->report_queue, | 408 | res = wait_event_interruptible_timeout(session->report_queue, |
406 | !test_bit(HIDP_WAITING_FOR_SEND_ACK, &session->flags), | 409 | !test_bit(HIDP_WAITING_FOR_SEND_ACK, &session->flags) |
410 | || atomic_read(&session->terminate), | ||
407 | 10*HZ); | 411 | 10*HZ); |
408 | if (res == 0) { | 412 | if (res == 0) { |
409 | /* timeout */ | 413 | /* timeout */ |