greybus: Ensure gb->mutex is held when adding timer
authorBryan O'Donoghue <bryan.odonoghue@linaro.org>
Wed, 16 Mar 2016 11:29:59 +0000 (11:29 +0000)
committerGreg Kroah-Hartman <gregkh@google.com>
Thu, 17 Mar 2016 04:49:31 +0000 (21:49 -0700)
commitfece9c87cb80aceec7dd0205a77c37ff7ba831fe
tree32c098bd6755ded2c95b096b88250b3a678d34d0
parent1dc8d3d7c568d9a80fa20570a764da57677f1050
greybus: Ensure gb->mutex is held when adding timer

Currently in loopback on the async path we issue an operation and then add
a timer to time-out that operation should it fail to complete. Looking at a
backtrace given in its feasible op_async->pending can be true and
del_timer() can run before add_timer() has run. In the callback handler we
already hold gb->mutex. This patch fixes that potential race by ensuring we
hold gb->mutex both when we are adding and when we are removing the
relevant timer.

Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Reported-and-tested-by: Axel Haslam <ahaslam@baylibre.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
drivers/staging/greybus/loopback.c