Bluetooth: btusb: Fix race when waiting for BTUSB_DOWNLOADING
authorJohan Hedberg <johan.hedberg@intel.com>
Fri, 30 Jan 2015 08:58:54 +0000 (10:58 +0200)
committerMarcel Holtmann <marcel@holtmann.org>
Fri, 30 Jan 2015 10:03:19 +0000 (11:03 +0100)
commita087a98e0767cf6c4f2480e6de5441497c9ba5b7
treecff12cae86d3e8b4633d65b57b334c9b9885ebd7
parent74d9daafa5e0b4f9183540b41b337d42662f537b
Bluetooth: btusb: Fix race when waiting for BTUSB_DOWNLOADING

The test for BTUSB_DOWNLOADING must be after adding to the wait queue
and setting the TASK_INTERRUPTIBLE state. Otherwise the flag may get
cleared after we test for it and we end up getting a timeout since
schedule_timeout() waits for the full duration. This patch uses a
wait_on_bit_timeout() + wake_up_bit(). To perform the task both
race-free as well as in a much simpler way.

Since there's no global wait_on_bit_timeout() helper yet (even though
all the building blocks for it are in place) this patch creates a
temporary local btusb copy of it until the global one has made it to
upstream trees.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
drivers/bluetooth/btusb.c
This page took 0.025588 seconds and 5 git commands to generate.